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 (x; 1..N-1) {
        long rr;
        if ((N-1) % x == 0) {
            for (int i, j = N-1; i < j; i += x, j -= x) rr += ss[i] + ss[j];
        } else {
            int i;
            for (; i < N-1; i += x) rr += ss[i];
            rr -= ss[i-x];
            i = N-1;
            for (; i > 0; i -= x) rr += ss[i];
            rr -= ss[i+x];
        }
        r = max(r, rr);
    }

    writeln(r);
}