#arc085c. [arc085_c]MUL
[arc085_c]MUL
Problem Statement
We have gemstones labeled through .
You can perform the following operation any number of times (possibly zero).
- Select a positive integer , and smash all the gems labeled with multiples of .
Then, for each , if the gem labeled remains without getting smashed, you will receive yen (the currency of Japan). However, 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.
Input
Input is given from Standard Input in the following format:
Output
Print the maximum amount of money that can be earned.
Sample Input 1
6
1 2 -6 4 5 3
Sample Output 1
12
It is optimal to smash Gem and .
Sample Input 2
6
100 -100 -100 -100 100 -100
Sample Output 2
200
Sample Input 3
5
-1 -2 -3 -4 -5
Sample Output 3
0
It is optimal to smash all the gems.
Sample Input 4
2
-1000 100000
Sample Output 4
99000