implicit none
integer(8):: n, i, j, ans, k, c, f
integer(8), allocatable, dimension(:):: a, b

read(5,*) n
allocate(a(n))
allocate(b(n))
read(5,*) (a(i),i=1,n)
j = -10 ** 10_8
ans = 0
do 10 c = 1, n - 1
    b = a
    f = 0
    do 20 k = 0, int((n - 1) / C)
        if (k * C + 1 == (n - 1) - k * C + 1 .or. b(k * C + 1) == j .or. b((n - 1) - k * C + 1) == j) then
            goto 10
        endif
        f = f + b(k * C + 1) + b((n - 1) - k * C + 1)
        ans = max(ans, f)
        b(k * C + 1) = j
        b((n - 1) - k * C + 1) = j
        
    20 continue
10 continue

write(6, *) ans

end