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

ans = 0
(1 .. N - 1).each do |c|
   x = 0
   l, r = 0, N - 1
   if (N - 1) % c == 0
     while l < r
       x += Ss[l] + Ss[r]
       l += c
       r -= c
     end
   else
     while l + c < N - 1
       x += Ss[l] + Ss[r]
       l += c
       r -= c
     end
   end
   ans = [ans, x].max
 end
 puts ans