// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef pair<int,int> P;



#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)

#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)



int const MAX_N = 100000;

vector<ll> prime;

vector<bool> is_prime(MAX_N,true);

void Eratosthenes() {

    is_prime[0] = is_prime[1] = false;

    for (ll i = 2;i*i < MAX_N;++i) if (is_prime[i]) for (ll j = 2*i;j < MAX_N;j += i) is_prime[j] = false;

    for (ll i = 0;i < MAX_N;++i) if (is_prime[i]) prime.push_back(i);

}



vector<P> prime_factorization(ll a) {

    vector<P> prime_factor;

    if (is_prime[0]) Eratosthenes();

    for (ll& i : prime) {

        if (i*i > a) break;

        if (a%i == 0) {

            P p = P(i,0);

            while (a%i == 0) {

                a /= i;

                p.second++;

            }

            prime_factor.push_back(p);

        }

    }

    if (a != 1) prime_factor.push_back(P(a,1));

    return prime_factor;

}



void rec(vector<ll>& div,vector<P>& fact,int i,ll d) {

    if (i == fact.size()) {

        div.push_back(d);

        return;

    }

    for (int j = 0;j <= fact[i].second;++j) {

        rec(div,fact,i+1,d);

        d *= fact[i].first;

    }

}



int main() {

    int n;

    ll k,sum = 0;

    cin >> n >> k;

    vector<int> a(n);

    for (int i = 0;i < n;++i) {

        scanf("%d",&a[i]);

        sum += a[i];

    }

    vector<P> b = prime_factorization(sum);

    vector<ll> div;

    rec(div,b,0,1);

    sort(div.begin(),div.end());

    reverse(div.begin(),div.end());

    for (ll d : div) {

        vector<ll> x,y;

        for (int i = 0;i < n;++i) {

            ll c = a[i]/d*d;

            if (a[i] == c) continue;

            x.push_back(a[i]-c);

            y.push_back(c+d-a[i]);

        }

        int m = x.size();

        x.push_back(0);

        y.push_back(0);

        sort(x.begin(),x.end());

        sort(y.begin(),y.end());

        for (int i = 0;i < m;++i) {

            x[i+1] += x[i];

            y[i+1] += y[i];

        }

        ll cnt = 1e9;

        for (int i = 0;i < m+1;++i) if (x[i] == y[m-i]) cnt = min(cnt,x[i]);

        if (cnt <= k) {

            cout << d << endl;

            return 0;

        }

    }

}

// Faster C++ solution for the same problem (measured speedup: 1.8273910902191626x):
#include<bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef pair<int,int> P;



#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)

#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)



int main() {

    int n,k,sum = 0;

    cin >> n >> k;

    vector<int> a(n);

    vector<int> div;

    for (int i = 0;i < n;++i) {

        cin >> a[i];

        sum += a[i];

    }

    for (ll i = 1;i*i <= sum;++i) if (sum%i == 0) {

        div.push_back(i);

        if (sum != i*i) div.push_back(sum/i);

    }

    sort(div.begin(),div.end());

    reverse(div.begin(),div.end());

    for (int d : div) {

        vector<int> x;

        ll s = 0;

        for (int i = 0;i < n;++i) if (a[i]%d) {

            x.push_back(a[i]%d);

            s += a[i]%d;

        }

        sort(x.begin(),x.end());

        if (s%d == 0) {

            ll t = 0;

            for (int i = x.size()-s/d-1;i >= 0;--i) t += x[i];

            if (t <= k) {

                cout << d << endl;

                return 0;

            }

        }

    }

}