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

void main()
{
    auto N = readln.chomp.to!int;
    auto AS = [0L] ~ readln.split.to!(long[]);

    auto as = AS;
    foreach (_; 0..101) {
        foreach_reverse (i, a; as) {
            if (!i) break;
            long sum;
            foreach (j, b; as) if (j % i == 0) sum += b;
            if (sum < 0) {
                auto sum_a = as.sum;
                auto bs = as.dup;
                foreach (j, ref b; bs) if (j % i == 0) b = 0;
                auto sum_b = bs.sum;
                if (sum_b > sum_a) as = bs;
            }
        }
    }
    writeln(as.sum);
}