#include<bits/stdc++.h>
#define M 505
using namespace std;
int A[M],n,sum,m,W[M],tail;
int main(){
	int ans=1;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]),sum+=A[i];
	for(int i=1;i<=sqrt(sum);i++){
		if(sum%i!=0)continue;
		for(int j=1;j<=n;j++)W[j]=A[j]%i;
		sort(W+1,W+n+1);
		int R=n;
		long long tot=0;
		for(int j=1;j<=n;j++){
			while(R>=j&&i-W[R]<W[j])tot+=i-W[R],W[j]-=(i-W[R]),W[R]=0,R--;
			if(R>j)W[R]+=W[j],tot+=W[j],W[j]=0;
		}
		if(tot<=m)ans=max(ans,i);
		int now=sum/i;
		for(int j=1;j<=n;j++)W[j]=A[j]%now;
		sort(W+1,W+n+1);
		R=n;
		tot=0;
		for(int j=1;j<=n;j++){
			while(R>=j&&now-W[R]<W[j])tot+=now-W[R],W[j]-=(now-W[R]),W[R]=0,R--;
			if(R>j)W[R]+=W[j],tot+=W[j],W[j]=0;
		}
		if(tot<=m)ans=max(ans,now);
	}
	printf("%d\n",ans);
	return 0;
}