#ARC085C. [ARC085E] MUL

[ARC085E] MUL

Score : 700700 points

Problem Statement

We have NN gemstones labeled 11 through NN.

You can perform the following operation any number of times (possibly zero).

  • Select a positive integer xx, and smash all the gems labeled with multiples of xx.

Then, for each ii, if the gem labeled ii remains without getting smashed, you will receive aia_i yen (the currency of Japan). However, aia_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.
  • 1N1001 \leq N \leq 100
  • ai109|a_i| \leq 10^9

Input

Input is given from Standard Input in the following format:

NN

a1a_1 a2a_2 ...... aNa_N

Output

Print the maximum amount of money that can be earned.

6
1 2 -6 4 5 3
12

It is optimal to smash Gem 33 and 66.

6
100 -100 -100 -100 100 -100
200
5
-1 -2 -3 -4 -5
0

It is optimal to smash all the gems.

2
-1000 100000
99000