output_description: Print the maximum amount of money that can be earned.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      a_1 a_2 ... a_N
attempt: n = int(input())
  a = [int(i) for i in input().split()]
  sum = 0
  ans = 0
  for i in range(n):
      x = n - i
      sum = 0
      for j in range(n // x):
          sum += a[x * (j + 1) - 1]
      if sum < 0:
          for k in range(n // x):
              a[x * (k + 1) - 1] = 0
  for j in range(n):
      ans += a[j]
  print(ans)
  
problem_description: 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?
samples: [{"input": "6\n    1 2 -6 4 5 3", "output": "12\n    \n\nIt is optimal to smash Gem 3 and 6.\n\n* * *"}, {"input": "6\n    100 -100 -100 -100 100 -100", "output": "200\n    \n\n* * *"}, {"input": "5\n    -1 -2 -3 -4 -5", "output": "0\n    \n\nIt is optimal to smash all the gems.\n\n* * *"}, {"input": "2\n    -1000 100000", "output": "99000"}]