import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto ss = readln.split.to!(long[]);

    long r;
    foreach (s; ss) r += s;
    if (N%2 == 1) r -= ss[N/2];
    r = max(0, r);
    foreach (x; 2..N-1) {
        long rr;
        int i, j = N-1;
        while (i < N-1 && j > 0) {
            rr += ss[i] + ss[j];
            if (i+x == j) goto done;
            if (i == j) {
                rr = -1;
                goto done;
            }
            i += x;
            j -= x;
        }
        rr = rr - ss[i-x] - ss[j+x];
        done:
        r = max(r, rr);
    }

    writeln(r);
}