#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
using ll = long long;
using namespace std;
ll n,k,s=0,a[550],b[550],ans=0;
ll f(ll w){
    ll s2=0,s3=0;
    rep(i,0,n){b[i]=a[i]%w;s2+=b[i];} 
    sort(b,b+n);
    rep(i,0,n-s2/w)s3+=b[i];  //s2/w ... 
    if(s3<=k) return w;
    else return 0;
}
int main(){
    cin>>n>>k;
    rep(i,0,n) {cin>>a[i];s+=a[i];}
    for(ll p=1;(p*p)<=s;p++) if(s%p==0){//自信を除くsの約数の最大は√s1よりp*p<=s
        ans=max(ans,f(p));              //前から
        if(s%p==0)ans=max(ans,f(s/p)); //後ろから
    }
    cout<<ans;
}
