#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,k,a[505],M[1000005],sum;
bool cmp(int a,int b){
	return M[a]<M[b];
}
bool chk(int x){			
	for(int i=1;i<=n;++i)M[a[i]]=a[i]%x;
	sort(a+1,a+1+n,cmp);
	int pre=0,suf=0;
	for(int i=1;i<=n;++i)suf+=(x-M[a[i]]);
	for(int i=1;i<=n;++i){
		pre+=M[a[i]];suf-=(x-M[a[i]]);
		if(pre==suf) {return pre<=k;}
	}
	return 0;
}
signed main(){
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;++i){
		scanf("%lld",&a[i]);
		sum+=a[i];
	}
	int ans=0;
	for(int i=1;i*i<=sum;++i){
		if(sum%i==0){
			int a=sum/i;
			if(chk(a)){printf("%lld\n",a);return 0;}
			if(chk(i))ans=i;
		}
	}
	printf("%lld\n",ans);
	return 0;
} 
