def frog_jump(n, s)
  max = 0
  1.upto(n / 2) do |c|
    k = 0
    point = 0
    used = []
    while !used.include?(k * c) && !used.include?(n - 1 - k * c) && k * c < n - 1 && k * c != n - 1 - k * c
      point += s[k * c] + s[n - 1 - k * c]
      used << k * c
      used << n - 1 - k * c
      k += 1
      max = [max, point].max
    end
  end
  max
end

n = gets.chomp.to_i
s = gets.split.map(&:to_i)
puts frog_jump(n, s)