n = gets.chomp.to_i
s = gets.chomp.split.map(&:to_i)

max = 0
(1..(n/2 - 1)).each do |i|
  sum = 0
  left, right = i, n-1-i
  while i < right do
    sum += s[left] + s[right]
    break if right%i==0 && left >= right
    max = sum if max < sum
    left += i
    right -= i
  end
end
puts(max)