atcoder#ARC085C. [ARC085E] MUL
[ARC085E] MUL
Score : points
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.
6
1 2 -6 4 5 3
12
It is optimal to smash Gem and .
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