require 'prime'
#約数一覧
def divisors(n)
  n.prime_division.inject([1]) do |ary, (p, e)|
    (0..e).map{ |e1| p ** e1 }.product(ary).map{ |a, b| a * b }
  end.sort
end

N = gets.to_i
S = gets.chomp.split(" ").map(&:to_i)

ans = 0
(3...N - 1).each{|a|
  divisors(N - 1 - a).each{|i|
    break if i >= a
    b, sum, po = [a - i, 0, 0]
    break if i == 1 && (N - 1) >= (2 * a)
    break if a == 2 * b && (N - 1) > (a + a / 2)
    while(po < N - 1) do
      sum += S[po + a]
      break if po + a == N - 1
      po += a - b
      sum += S[po]
    end
    ans = sum if sum > ans
  }
}

puts ans
