There is an infinitely large pond, which we consider as a number line.
In this pond, there are N lotuses floating at coordinates 0, 1, 2, ..., N-2 and N-1.
On the lotus at coordinate i, an integer s_i is written.
You are standing on the lotus at coordinate 0. You will play a game that proceeds as follows:
 - 1. Choose positive integers A and B. Your score is initially 0.
 - 2. Let x be your current coordinate, and y = x+A. The lotus at coordinate x disappears, and you move to coordinate y.
 - If y = N-1, the game ends.
 - If y \neq N-1 and there is a lotus floating at coordinate y, your score increases by s_y.
 - If y \neq N-1 and there is no lotus floating at coordinate y, you drown. Your score decreases by 10^{100} points, and the game ends.
 - 3. Let x be your current coordinate, and y = x-B. The lotus at coordinate x disappears, and you move to coordinate y.
 - If y = N-1, the game ends.
 - If y \neq N-1 and there is a lotus floating at coordinate y, your score increases by s_y.
 - If y \neq N-1 and there is no lotus floating at coordinate y, you drown. Your score decreases by 10^{100} points, and the game ends.
 - 4. Go back to step 2.
You want to end the game with as high a score as possible.
What is the score obtained by the optimal choice of A and B?

-----Constraints-----
 - 3 \leq N \leq 10^5
 - -10^9 \leq s_i \leq 10^9
 - s_0=s_{N-1}=0
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
N
s_0 s_1 ...... s_{N-1}

-----Output-----
Print the score obtained by the optimal choice of A and B.

-----Sample Input-----
5
0 2 5 1 0

-----Sample Output-----
3

If you choose A = 3 and B = 2, the game proceeds as follows:
 - Move to coordinate 0 + 3 = 3. Your score increases by s_3 = 1.
 - Move to coordinate 3 - 2 = 1. Your score increases by s_1 = 2.
 - Move to coordinate 1 + 3 = 4. The game ends with a score of 3.
There is no way to end the game with a score of 4 or higher, so the answer is 3. Note that you cannot land the lotus at coordinate 2 without drowning later.

Difficulty: interview

Starter code:

Solutions:
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())
S = list(map(int, sys.stdin.readline().split()))


def count_max(diff):
    # 左右対称に diff 間隔でとるときの最大
    b = 0
    a = N - 1
    ret = 0
    cumsum = 0
    while diff < a and a != b and b - a != diff:
        cumsum += S[b] + S[a]
        ret = max(ret, cumsum)
        b += diff
        a -= diff
    return ret


ans = 0
for diff in range(1, N // 2 + 1):
    ans = max(ans, count_max(diff))
print(ans)


n = int(input())
s = list(map(int, input().split()))

ans = 0
for d in range(1, (n-1)//2+1):
    ans_cur = 0
    l, r = 0, n-1
    while r > d and l != r and l != r+d:
        ans_cur += s[l]+s[r]
        ans = max(ans, ans_cur)
        l += d
        r -= d
print(ans)

import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N = II()
    S = LI()
    ans = 0
    for C in range(1, N):
        tmp = 0
        L = 0
        lim = (N - 1 - C) if (N - 1) % C else (N // 2)
        while L < lim:
            tmp += S[L] + S[-1 - L]
            ans = max(ans, tmp)
            L += C
    return ans

print(main())

n,*s=map(int,open(0).read().split())
m=0
for i in range(1,n):
    t=0
    for j in range(0,n,i):
        k=n-1-j
        if k<i or k%i<1 and k<=j:break
        t+=s[j]+s[k]
        if t>m:m=t
print(m)

n=int(input())
v=list(map(int, input().split()))
ans=0
for k in range(1,n):
	p,s=k,0
	while p<n:
		r=n-p-1
		if r<=k:
			break
		s+=v[p]+v[n-1-p]
		if r%k!=0 or p<r:
			ans=max(ans,s)
		p+=k
print(ans)

import sys
def single_input(F): return F.readline().strip("\n")
def line_input(F): return F.readline().strip("\n").split()
  
def solve():
    F = sys.stdin
    N = int(single_input(F))
    S = [int(s) for s in line_input(F)]
    
    maxpoint = 0
    for c in range(1, N//2):
        s, l = 0, N-1
        point = 0
        if (N-1) % c == 0:
            while l > s and l > c:
                point += S[s] + S[l]
                maxpoint = max(point, maxpoint)
                s += c
                l -= c
        else:
            while l != s and l > c:
                point += S[s] + S[l]
                maxpoint = max(point, maxpoint)
                s += c
                l -= c
    print(maxpoint)
    return 0
  
def __starting_point():
    solve()
__starting_point()

import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N = II()
    S = LI()
    ans = 0
    for C in range(1, N):
        tmp = 0
        L = 0
        R = N - 1
        lim = (N - 1 - C) if (N - 1) % C else (N // 2)
        while L < lim:
            tmp += S[L] + S[R]
            ans = max(ans, tmp)
            L += C
            R -= C
    return ans

print(main())

n = int(input())
a = [int(i) for i in input().split()]

ans = 0
for C in range(1, n):
    f = 0
    for k in range([int(((n - 1) / C + 1) / 2), int((n - 1) / C)][(n - 1) % C != 0]):
        f += a[k * C] + a[(n - 1) - k * C]
        ans = max(ans, f)
print(ans)

from collections import defaultdict
N = int( input())
S = list( map( int, input().split()))

ans = 0
for c in range(1,N):
    now = 0
    for t in range(c ,N, c):
        if ((N-1-t)%c == 0 and N-1-t <= t) or N-1-t - c <=0:
            break
        now += S[t] + S[N-1-t]
        if now > ans:
            ans = now
print(ans)


import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7

def read_values(): return list(map(int, input().split()))
def read_index(): return [int(x) - 1 for x in input().split()]
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n) 


def main():
    N = int(input())
    S = read_list()

    res = V(max, 0)
    for c in range(1, N):
        r = 0
        t1 = 0
        t2 = N - 1
        while True:
            t1 += c
            t2 -= c
            if t2 < c:
                break
            
            if (N - 1) % c == 0 and 2 * t2 <= N - 1:
                break

            r += S[t1] + S[t2]
            res.ud(r)

    print(res)


def __starting_point():
    main()

__starting_point()

import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N = II()
    S = LI()
    S = S[:-1]
    ans = 0
    for C in range(1, N):
        tmp = 0
        L = 0
        lim = (N - 1 - C) if (N - 1) % C else (N // 2)
        while L < lim:
            tmp += S[L] + S[-L]
            ans = max(ans, tmp)
            L += C
    return ans

print(main())

import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    S = list(map(int, input().split()))

    ans = 0
    for C in range(1, N):
        n = N // C
        dp = [0] * n
        used = set([0])
        for k in range(1, n):
            A = N - 1 - k*C
            if A in used or k*C in used or A == k*C:
                break
            used.add(A)
            used.add(k*C)

            dp[k] = dp[k-1] + S[A] + S[k*C]

        ans = max(ans, max(dp))

    return ans


def __starting_point():
    print((main()))

__starting_point()

import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    S = list(map(int, input().split()))

    ans = 0
    # C = A - B
    for C in range(1, N//2):
        n = (N-1) // C
        point = 0
        for k in range(1, n):
            A = N-1 - k*C

            # Check A and B are positive integer, and S_i is not used twice.
            #
            # B = A - C and B >= 0, so A must be over C (A > C).
            #
            # If C is aliquot of N-1 (N-1 % C = 0), A is also aliquot of N-1
            # (N-1 % A = 0) because A + kC = N-1. Therefore when A is less than
            # or equal kC, the A's value is already used by kC.
            if A < C or ((N-1) % C == 0 and A <= k*C):
                break

            point += S[A] + S[k*C]
            ans = max(ans, point)

    return ans


def __starting_point():
    print((main()))

__starting_point()

import sys
input = sys.stdin.readline

n = int(input())
S = tuple(map(int, input().split()))
ans = 0
for c in range(1, n-1):
  temp = 0
  T = set()
  for k in range(n):
    d = c*k
    if d+c >= n:
      break
    if d == n-1-d or d in T or n-1-d in T:
      break
    T.add(d)
    T.add(n-1-d)
    temp += S[d]+S[n-1-d]
    ans = max(ans, temp)
print(ans)

import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7

def read_values(): return list(map(int, input().split()))
def read_index(): return [int(x) - 1 for x in input().split()]
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n) 


def main():
    N = int(input())
    S = read_list()

    res = V(max, 0)
    for c in range(1, N):
        r = 0
        t1 = 0
        while True:
            t1 += c
            if t1 > N - 1 - c:
                break
            
            if (N - 1) % c == 0 and 2 * t1 >= N - 1:
                break

            r += S[t1] + S[N - 1 - t1]
            res.ud(r)

    print(res)


def __starting_point():
    main()

__starting_point()

# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

n = int(input())
s = [int(i) for i in readline().split()]

n -= 1
ans = 0

for d in range(1,n+1):
    a = n-d
    res = 0
    p,q = n,0
    while a >= d:
        if a <= n-a and n%d == 0: break
        p -= d
        q += d
        res += s[p] + s[q]
#        print(d,a,res)
        if res > ans: ans = res
        a -= d
    
print(ans)    
    
    
    
    
    
    
    
    
    


n = int(input())
s = list(map(int, input().split()))
ans = 0
for i in range(1, (n-1)//2+1):
	res = 0
	l, r = i, n-1-i
	while r > i and l != r and l != r+i:
		res += s[l] + s[r]
		ans = max(ans, res)
		l += i
		r -= i
print(ans)

N = int(input())
S = list(map(int,input().split()))

ans = 0
for d in range(1,N):
    max_now = 0
    if (N-1) % d == 0:
        now = 0

        i, j = 0, N-1
        while i < j:
            now += S[i] + S[j]
            max_now = max(now, max_now)
            i += d
            j -= d
    else:
        now = 0

        i, j = 0, N-1
        while i < N-1 and j > d:
            now += S[i] + S[j]
            max_now = max(now, max_now)
            i += d
            j -= d
    
    ans = max(max_now, ans)

print(ans)

n = int(input())
a = [int(item) for item in input().split()]

ans = 0
for c in range(1, n):
    visited = set([0, n-1])
    total = 0
    for k in range(1, n):
        odd = n - 1 - k*c
        even = k * c
        if even >= n - 1:
            break
        if odd < c:
            break
        if even in visited:
            break
        visited.add(even)
        if odd in visited:
            break
        visited.add(odd)
        total += a[odd] + a[even]
        ans = max(ans, total)
        # print(c, k, total)
        # print(visited)
print(ans)

N = int(input())
*S, = map(int, input().split())

ans = 0
for d in range(1, N):
    r = k = 0
    while k*d <= N-1:
        a = N-1-k*d
        if a <= d or (a <= k*d and a % d == 0):
            break
        r += S[N-1-k*d] + S[k*d]
        k += 1
        ans = max(ans, r)
print(ans)

from itertools import accumulate

N, *S = map(int, open(0).read().split())

ans = 0
for dx in range(1, N - 1):

    k, r = divmod(N - 1, dx)
    if r == 0:
        k = (k + 1) // 2

    ans = max(ans, max(accumulate(a + b for a, b in zip(S[:dx * k:dx], S[N - 1:(N - 1) - dx * k:-dx]))))

print(ans)

N = int(input())
slist = list(map(int, input().split()))
ans = 0
for C in range(1,N-1,1):
    score = 0
    for k in range((N-1)//C):
        if (k-1)*C == N-1-k*C: #一つ前に選んだところ
            break
        if 2*k*C == N-1: #今から選ぶ二つが同じところ
            break
        score += slist[k*C]+slist[N-1-k*C]
        ans = max(ans, score)
print(ans)

n = int(input())
s = list(map(int, input().split()))
ans = 0
for i in range(1, n):
  l = 0
  r = n-1
  cur = 0
  while True:
    l += i
    r -= i
    if l>=n or r<=i or (r%i==0 and r<=l):
      break
    cur += s[l] + s[r]
    ans = max(ans, cur)
print(ans)

import numpy as np

N = int(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
input = sys.stdin.readline

N=int(input())
S=list(map(int,input().split()))

ANS=0

for i in range(1,N//2):
    s=0
    l=N-1
    SCORE=0

    if (N-1)%i==0:
        while l>s and l>i:

            SCORE+=S[s]+S[l]
            ANS=max(ANS,SCORE)
            s+=i
            l-=i
        #print(SCORE,i,l,s)
    else:
        while l!=s and l>i:

            SCORE+=S[s]+S[l]
            ANS=max(ANS,SCORE)
            s+=i
            l-=i

        #print(SCORE,i,l,s)

print(ANS)

n = int(input())
sss = list(map(int, input().split()))

ans = 0
for c in range(1, n // 2):
    a = n - 1 - c
    k = c
    tmp = 0
    while a > c and a != k and a + c != k:
        tmp += sss[a] + sss[k]
        ans = max(ans, tmp)
        a -= c
        k += c
print(ans)


N = int(input())
S = list(map(int, input().split()))
L = 0;  R = N-1
ans = 0
for i in range(1, (N+1)//2):
    r = R
    l = L
    j = 1
    a = 0
    Closed = set()
    while True:
        l += i
        Closed.add(l)
        r -= i
        if r in Closed:
            break
        Closed.add(r)
        if r < i:
            break
        a += S[l] + S[r]
        ans = max(ans, a)
        j += 1
print(ans)


n = int(input())
s = list(map(int, input().split()))

ans = 0
for step in range(1, n):
    now = 0
    for i, j in zip(list(range(0, n, step)), list(range(n - 1, -1, -step))):
        if i == j or i - j == step or j < step:
            break
        now += s[i] + s[j]
        ans = max(ans, now)
print(ans)


N = int(input())
S = list(map(int, input().split()))

ans = 0
for C in range(1, N):
    fkC = 0
    L = 0
    R = N-1
    if ((N-1) % C == 0):
        while L < R:
            fkC += S[L] + S[R]
            ans = max(ans, fkC)
            L += C
            R -= C
    else:
        while L+C < N-1:
            fkC += S[L] + S[R]
            ans = max(ans, fkC)
            L += C
            R -= C

print(ans)

n = int(input())
s = list(map(int, input().split()))
MINUS_INF = -float("inf")
ans = 0
for c in range(1, n):
    k = 1
    tmp_ans = 0
    while k * c < n - 1:
        a = (n - 1) - k * c
        b = a - c
        if a <= b or b <= 0:
            tmp_ans = MINUS_INF
        if a % c == 0 and a // c <= k:
            tmp_ans = MINUS_INF
        tmp_ans += s[n-1-k*c] + s[k*c]
        ans = max(ans, tmp_ans)    
        k += 1    
print(ans)

import sys
input = sys.stdin.readline
N = int(input())
S = list(map(int, input().split()))
N -= 1
ans = 0
for d in range(1,N+1):
    a = N-d
    res = 0
    p,q = N,0
    while a >= d:
        if a <= N-a and N%d == 0:
            break
        p -= d
        q += d
        res += S[p] + S[q]
        if res > ans:
            ans = res
        a -= d
    
print(ans)   

N = int(input())
s = list(map(int, input().split()))
ans = 0
for c in range(1, N):
    res = 0
    for k in range(1, (N-1)//c+1):
        a = N-1-c*k
        b = a-c
        res+=s[c*k]+s[-c*k-1]
        if b<0 or (a%c==0 and a//c<=k) :
            continue
        ans = max(ans, res)
print(ans)


        


N = int(input())
ss = list(map(int, input().split()))

ans = 0
for C in range(1, N):
    score = 0
    for k in range(1, (N-1)//C+1):
        if (N-1)%C == 0 and k*C >= N-1-k*C: break
        if N-1-k*C <= C: break
        score += ss[k*C] + ss[N-1-k*C]
        ans = max(ans, score)

print(ans)


N = int(input())
S = [int(a) for a in input().split()]
ma = 0
for C in range(1, N-1):
    s = 0
    for k in range((N-2) // C):
        A = N-1-k*C
        if A % C == 0 and A//C <= k: continue
        s += S[k*C] + S[-1-k*C]
        ma = max(ma, s)

print(ma)

n = int(input())
s = list(map(int,input().split()))

ans = 0

for c in range(1,n-1):
  if (n-1)%c == 0:
    p = ((n-1)//c-1)//2 
  else:
    p = (n-1)//c-1
    if p <= 0:
      break
  if p <= 0:
    continue
  m = 0
  k = 0
  for i in range(1,p+1):
    k += s[c*i] + s[n-1-c*i]
    m = max(m,k)
  ans = max(ans,m)
    
    
print(ans)

N = int(input())
S = list(map(int,input().split()))

ans = 0
for C in range(1,N):
    dp = 0
    for k in range((N-1)//C):
        if (2*k-1)*C == N-1 or 2*k*C == N-1:
            break
        dp += S[N-1-C*k]+S[C*k]
        ans = max(ans,dp)

print(ans)

###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict
import math


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    nonlocal mod
    return (x + y) % mod


def modmlt(x, y):
    nonlocal mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    ret = math.factorial(x)
    ret = ret // (math.factorial(x - y) * math.factorial(y))

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in list(distance_list.items()):
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


class UnionFind:

    def __init__(self, n):
        self.parent = [i for i in range(n)]

    def root(self, i):
        if self.parent[i] == i:
            return i
        self.parent[i] = self.root(self.parent[i])
        return self.parent[i]

    def unite(self, i, j):
        rooti = self.root(i)
        rootj = self.root(j)
        if rooti == rootj:
            return
        if rooti < rootj:
            self.parent[rootj] = rooti
        else:
            self.parent[rooti] = rootj

    def same(self, i, j):
        return self.root(i) == self.root(j)


###############################################################################


def main():
    n = intin()
    alist = intina()

    ans = 0

    for i in range(1, n//2):
        lsum = 0
        for j in range(1, n):
            down = n - i * j - 1
            up = i * j
            if (down <= up and down % i == 0):
                break
            if (down <= i):
                break
            if (n - 1 - up <= i):
                break
            lsum += alist[down]
            lsum += alist[up]
            ans = max(ans, lsum)

    print(ans)


def __starting_point():
    main()

__starting_point()

# youtube
n = int(input())
s = list(map(int, input().split()))
ans = 0
for d in range(1, n - 1):
    ten = 0
    passed = set([0, n - 1])
    l = 0
    r = n - 1
    for _ in range((n - 1) // d):
        l += d
        r -= d
        if l in passed or r in passed or l==r or r < d:
            break
        ten += s[l]
        ten += s[r]
        passed.add(l)
        passed.add(r)
        if ten > ans:
            ans = ten
print(ans)


N=int(input())
s=[int(i) for i in input().split()]
ans=0
for C in range(1,N):
    fkC=0
    L=0;R=N-1
    if ((N-1)%C==0):
        while(L<R):
            fkC+=s[L]+s[R]
            ans=max(ans,fkC)
            L+=C
            R-=C
    else:
        while(L+C<N-1):
            fkC+=s[L]+s[R]
            ans=max(ans,fkC)
            L+=C
            R-=C
print(ans)

n = int(input())
l = list(map(int,input().split()))

ans = 0
for c in range(1,n):
    now = 0
    pas = set()
    for k in range(1,n):
        if k * c > n-1 or n-1-k*c <= c:
            break
        if n-1-k*c in pas or k*c in pas or n-1 == 2*k*c:
            break 
        now += l[n-1-k*c] + l[k*c]
        pas.add(n-1-k*c)
        pas.add(k*c)
        ans = max(ans,now)
        
print(ans)


N = int(input())
s = list(map(int, input().split()))
ans = 0
for C in range(1,N):
    t = 0
    for x in range(C, N-1-C if (N-1)%C != 0 else N//2, C):
        t += s[x] + s[-x-1]
        ans = max(ans, t)
print(ans)

n,*s=map(int,open(0).read().split());a=0
for i in range(1,n):
 t=0
 for j in range(0,[n//2,n+~i][(n-1)%i>0],i):t+=s[j]+s[~j];a=max(a,t)
print(a)

import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    S = list(map(int, input().split()))

    ans = 0
    for C in range(1, N//2):
        n = N // C
        point = 0
        used = set([0])
        for k in range(1, n):
            A = N - 1 - k*C

            if A in used or k*C in used or A == k*C:
                break
            used.add(A)
            used.add(k*C)

            point += S[A] + S[k*C]
            ans = max(ans, point)

    return ans


def __starting_point():
    print((main()))

__starting_point()

n = int(input())
v = list(map(int, input().split()))
ans = 0
for k in range(1, n):
	p, s = k, 0
	while p < n:
		r = n - p - 1
		if r <= k:
			break
		s += v[p] + v[n - 1 - p]
		if r % k != 0 or p < r:
			ans = max(ans, s)
		p += k
print(ans)

import itertools
N = int(input())
S = [int(_) for _ in input().split()]

ans = 0
for i in range(1, N - 1):
    maxj = (N - 1) // i
    if (N - 1) % i == 0:
        maxj = ((N - 1) // i + 1) // 2
    dp = itertools.accumulate(
        x + y for x, y in zip(S[:i * maxj:i], S[-1:-1 - i * maxj:-i]))
    ans = max(ans, max(dp))
print(ans)


def f_frog_jump(N, S):
    ans = 0
    for c in range(1, N):
        # k=0のとき、スタートからゴールへ飛ぶしかない(得点0)ので、k=1から始める
        current_ans, k = 0, 1
        while k * c < N - 1:
            a = N - 1 - k * c
            b = a - c
            # k, cを決めたとき、進む距離<=戻る距離になる(負の座標に到達する)か、
            # 同じ座標に複数回到達する場合、得点を計算する意味がない
            if not (a <= b or b <= 0 or (a % c == 0 and a <= k * c)):
                current_ans += S[N - 1 - k * c] + S[k * c]
                ans = max(ans, current_ans)
            k += 1
    return ans
    # 参考: http://sigma1113.hatenablog.com/entry/2019/05/27/181729

N = int(input())
S = [int(i) for i in input().split()]
print(f_frog_jump(N, S))

def cumsum(itr):
    arr = []
    val = 0
    for x in itr:
        val += x
        arr.append(val)
    return arr


def main(N, scores):
    M = N - 1

    def max_score(d):
        steps = (scores[i] + scores[-i - 1] for i in range(0, M - d, d))
        cum_scores = cumsum(steps)

        if M % d > 0:
            return max(cum_scores)
        else:
            k = M // d + 1
            return max(cum_scores[: k // 2])

    corner_case = scores[0] + scores[M]
    otherwise = max(max_score(d) for d in range(1, M))
    return max(corner_case, otherwise)


N = int(input())
scores = [int(a) for a in input().split()]
result = main(N, scores)

print(result)

import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7

def read_values(): return list(map(int, input().split()))
def read_index(): return [int(x) - 1 for x in input().split()]
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n) 


def main():
    N = int(input())
    S = read_list()

    res = V(max, 0)
    for c in range(1, N):
        r = 0
        t1 = 0
        t2 = N - 1
        a = t2 - c
        while True:
            if a < c:
                break
            
            if (N - 1) % c == 0 and 2 * a <= N - 1:
                break

            t1 += c
            t2 -= c
            a -= c
            r += S[t1] + S[t2]
            res.ud(r)

    print(res)


def __starting_point():
    main()

__starting_point()