def solve(n,s,k)
  t = (n-1) % k == 0 ? n/2 : n-1
  dp = [0]
  i = k
  while i < t
    dp << dp[-1] + s[i] + s[n-1-i]
    i += k
  end
  return dp.max
end

N = gets.to_i
s = gets.split.map(&:to_i)
ans = 0
1.upto(N-1) do |k|
  tmp = solve(N,s,k)
  ans = tmp if ans < tmp
end
p ans