local mfl, mce = math.floor, math.ceil
local mmi, mma = math.min, math.max
local n = io.read("*n")
local t = {}
_u = io.read("*n")
for i = 1, n - 1 do
  t[i] = io.read("*n")
end
n = n - 1
local ret = 0
for i = 1, n do
  local c = 0
  for j = 1, n do
    if n % i == 0 then
      if n - i * j <= i * j then break end
    end
    if n - i * j < i then break end
    c = c + t[i * j] + t[n - i * j]
    ret = mma(ret, c)
  end
end
print(ret)
