AtCoder Regular Contest 085
翻译中…
Problem Statement
翻译中…
We have $N$ gemstones labeled $1$ through $N$.
翻译中…
You can perform the following operation any number of times (possibly zero).
翻译中…
- Select a positive integer
$x$, and smash all the gems labeled with multiples of$x$.
翻译中…
Then, for each $i$, if the gem labeled $i$ remains without getting smashed, you will receive $a_i$ yen (the currency of Japan). However, $a_i$ may be negative, in which case you will be charged money.
翻译中…
By optimally performing the operation, how much yen can you earn?
翻译中…
Constraints
翻译中…
- All input values are integers.
$1 \leq N \leq 100$$|a_i| \leq 10^9$
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N
a_1 a_2 ... a_N
翻译中…
Output
翻译中…
Print the maximum amount of money that can be earned.
翻译中…
样例
Input #1
6
1 2 -6 4 5 3
Output #1
12
It is optimal to smash Gem $3$ and $6$.
Input #2
6
100 -100 -100 -100 100 -100
Output #2
200
Input #3
5
-1 -2 -3 -4 -5
Output #3
0
It is optimal to smash all the gems.
Input #4
2
-1000 100000
Output #4
99000
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。