# I saw the editorial to solve this problem :-)
n = gets.to_i
s = gets.split.map(&:to_i)

max = 0
1.upto(n-1) do |c|
  k = 0
  a = 0
  next if (n-1) % c == 0
  while k * c < n - 1

    a += s[n - 1 - k * c] + s[k * c]
    k += 1
    max = [a, max].max
  end
end

p max
