import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto K = s[1].to!long;
    auto A = readln.split.map!(to!long).array;
    auto B = new long[][](N, 2);

    auto S = A.sum;
    long[] P;
    for (long i = 1; i * i <= S; ++i) {
        if (i * i == S) {
            P ~= i;
        } else if (S % i == 0) {
            P ~= i;
            P ~= S / i;
        }
    }
    P.sort();

    foreach_reverse (p; P) {
        foreach (i, a; A){
            B[i][0] = a % p;
            B[i][1] = (p - a % p) % p;
        }
        B.sort!"a[0]-a[1] < b[0]-b[1]";
        long tmp = 0;
        long sm = 0;
        for (int i = 0, j = N - 1; i < j; ) {
            long x = min(B[i][0], B[j][1]);
            tmp += x;
            B[i][0] -= x;
            B[j][1] -= x;
            if (B[i][0] == 0) i++;
            if (B[j][1] == 0) j--;
            sm += x;
        }
        if (sm <= K && B.map!(b => b[0] % p == 0 || b[1] % p == 0).all) {
            writeln(p);
            return;
        }
    }
}
