#include<bits/stdc++.h>
using namespace std;
int n,k,a[550],b[550],sum,ans=1;
bool solve(int x)
{
	int tot=0,ad=0;
	for(int i=1;i<=n;i++)
	{
		int rr=a[i]/x;
		b[i]=a[i]-rr*x;
		tot+=b[i];
		ad+=rr;
	}
	int nd=sum/x-ad;
	sort(b+1,b+n+1);
	for(int i=n;i>n-nd;i--)
	tot+=x-2*b[i];
	return tot/2<=k;
}
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),sum+=a[i];
	int sss=sqrt(sum);
	for(int i=1;i<=sss;i++)
	{
		if(sum%i!=0)continue;
		if(sum/i>ans)if(solve(sum/i))ans=sum/i;
		if(i>ans)if(solve(i))ans=i;
	}
	cout<<ans;
}