N = gets.to_i
Ss = gets.split.map(&:to_i)

ans = 0
(1 .. N/2).each do |c|
  l, r, x = 0, N - 1, 0
  while ((N - 1) % c == 0 && l < r) || ((N - 1) % c != 0 && l + c < N - 1)
    x += Ss[l] + Ss[r]
    l += c; r -= c
    ans = x if x > ans
  end
end
puts ans