import numpy as np



N = int(eval(input()))

S = np.array([int(x) for x in input().split()],dtype=np.int64)



# 右移動着地点：等差数列、ゴール含む

# 左移動着地点：等差数列、スタート含む



answer = 0

for d in range(1,N):

  # d = A-B

  cum_left = np.cumsum(S[::d])

  cum_right = np.cumsum(S[::-1][::d])

  score = cum_left + cum_right # 等差数列の長さ-1 -> 得点

  # あとは、その経路がルール内で実現できるかどうか

  for L,s in enumerate(score):

    if answer >= s:

      continue

    # 右左に進んでいることの確認

    A = N-1-L*d

    B = A-d

    if A <= 0:

      continue

    if A<=B:

      continue

    if B<=0:

      continue

    # 同じ場所を取っていないかの確認

    # kd = N-1-ldとなるとまずい

    # 約数のとき、Ld >= N-Ldだとまずい

    if (N-1)%d == 0 and 2*L*d >= N-1:

      continue

    answer = s



print(answer)

import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



import numpy as np



N = int(readline())

S = np.array(read().split(),np.int64)



def F(d):

    # 公差を固定

    L = S[:-d:d].cumsum()

    R = S[::-1][:-d:d].cumsum()

    if (N-1)%d == 0:

        n = (N-1)//d

        x = np.arange(1,n+1)

        bl = (x+x <= n+1)

        L = L[bl]; R = R[bl]

    return (L+R).max()



def G(n):

    # 項数n+1を固定

    D = (N-1-n)//n

    L = np.zeros(D+1,np.int64)

    R = np.zeros(D+1,np.int64)

    for i in range(1,n+1):

        L += S[:i*(D+1):i]

        R += S[::-1][:i*(D+1):i]

    ok = np.ones(D+1,np.bool)

    overlap = (np.arange(D+1) * (n+n) >= N-1)

    overlap[1:] &= ((N-1)%np.arange(1,D+1) == 0)

    x = L+R

    x[overlap] = 0

    return x.max()



L = int((N-1)**.5 + 10)

L = min(N-1,L)



x = max(F(n) for n in range(1,L+1))

y = max(G(n) for n in range(1,L+1))

answer = max(x,y)

print(answer)
import numpy as np

N = int(eval(input()))
S = np.array([int(x) for x in input().split()], dtype=np.int64)
# 右移動着地点：等差数列、ゴール含む
# 左移動着地点：等差数列、スタート含む
answer = 0
for d in range(1, N):
    # d = A-B
    cum_left = np.cumsum(S[::d])
    cum_right = np.cumsum(S[::-1][::d])
    score = cum_left + cum_right  # 等差数列の長さ-1 -> 得点
    # あとは、その経路がルール内で実現できるかどうか
    for L, s in enumerate(score):
        if answer >= s:
            continue
        # 右左に進んでいることの確認
        A = N - 1 - L * d
        B = A - d
        if A <= 0:
            continue
        if A <= B:
            continue
        if B <= 0:
            continue
        # 同じ場所を取っていないかの確認
        # kd = N-1-ldとなるとまずい
        # 約数のとき、Ld >= N-Ldだとまずい
        if (N - 1) % d == 0 and 2 * L * d >= N - 1:
            continue
        answer = s
print(answer)

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

N = int(readline())
S = np.array(read().split(), np.int64)


def F(d):
    # 公差を固定
    L = S[:-d:d].cumsum()
    R = S[::-1][:-d:d].cumsum()
    if (N - 1) % d == 0:
        n = (N - 1) // d
        x = np.arange(1, n + 1)
        bl = x + x <= n + 1
        L = L[bl]
        R = R[bl]
    return (L + R).max()


def G(n):
    # 項数n+1を固定
    D = (N - 1 - n) // n
    L = np.zeros(D + 1, np.int64)
    R = np.zeros(D + 1, np.int64)
    for i in range(1, n + 1):
        L += S[: i * (D + 1) : i]
        R += S[::-1][: i * (D + 1) : i]
    ok = np.ones(D + 1, np.bool)
    overlap = np.arange(D + 1) * (n + n) >= N - 1
    overlap[1:] &= (N - 1) % np.arange(1, D + 1) == 0
    x = L + R
    x[overlap] = 0
    return x.max()


L = int((N - 1) ** 0.5 + 10)
L = min(N - 1, L)
x = max(F(n) for n in range(1, L + 1))
y = max(G(n) for n in range(1, L + 1))
answer = max(x, y)
print(answer)

+import sys + +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines -N = int(eval(input())) -S = np.array([int(x) for x in input().split()], dtype=np.int64) -# 右移動着地点：等差数列、ゴール含む -# 左移動着地点：等差数列、スタート含む -answer = 0 -for d in range(1, N): -    # d = A-B -    cum_left = np.cumsum(S[::d]) -    cum_right = np.cumsum(S[::-1][::d]) -    score = cum_left + cum_right  # 等差数列の長さ-1 -> 得点 -    # あとは、その経路がルール内で実現できるかどうか -    for L, s in enumerate(score): -        if answer >= s: -            continue -        # 右左に進んでいることの確認 -        A = N - 1 - L * d -        B = A - d -        if A <= 0: -            continue -        if A <= B: -            continue -        if B <= 0: -            continue -        # 同じ場所を取っていないかの確認 -        # kd = N-1-ldとなるとまずい -        # 約数のとき、Ld >= N-Ldだとまずい -        if (N - 1) % d == 0 and 2 * L * d >= N - 1: -            continue -        answer = s +N = int(readline()) +S = np.array(read().split(), np.int64) + + +def F(d): +    # 公差を固定 +    L = S[:-d:d].cumsum() +    R = S[::-1][:-d:d].cumsum() +    if (N - 1) % d == 0: +        n = (N - 1) // d +        x = np.arange(1, n + 1) +        bl = x + x <= n + 1 +        L = L[bl] +        R = R[bl] +    return (L + R).max() + + +def G(n): +    # 項数n+1を固定 +    D = (N - 1 - n) // n +    L = np.zeros(D + 1, np.int64) +    R = np.zeros(D + 1, np.int64) +    for i in range(1, n + 1): +        L += S[: i * (D + 1) : i] +        R += S[::-1][: i * (D + 1) : i] +    ok = np.ones(D + 1, np.bool) +    overlap = np.arange(D + 1) * (n + n) >= N - 1 +    overlap[1:] &= (N - 1) % np.arange(1, D + 1) == 0 +    x = L + R +    x[overlap] = 0 +    return x.max() + + +L = int((N - 1) ** 0.5 + 10) +L = min(N - 1, L) +x = max(F(n) for n in range(1, L + 1)) +y = max(G(n) for n in range(1, L + 1)) +answer = max(x, y)