#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

namespace my
{
	//-----------------------------------------------------------------------------
	inline char cn()
	{
		static char buf[1000010],*p1=buf,*p2=buf;
		return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
	}
	#define cn getchar
	template<class TY>void read(TY &x)
	{
		x=0;int f1=1;char ch=cn();
		while(ch<'0'||ch>'9'){if(ch=='-')f1=-1;ch=cn();}
		while(ch>='0'&&ch<='9')x=x*10+(ch-'0'),ch=cn(); x*=f1;
	}
	char Output[1000100],Zk[100];int op_top=0,Zk_top;
	void fcheck(int Type=0){if(Type||op_top>=1000000)fwrite(Output,1,op_top,stdout),op_top=0;}
	template<class TY>inline void write(TY x)
	{
		if(x==0){Output[op_top++]='0';fcheck();return;}
		if(x<0)Output[op_top++]='-',x=-x;
		Zk_top=0;while(x)Zk[++Zk_top]=x%10+'0',x/=10;
		while(Zk_top)Output[op_top++]=Zk[Zk_top--];fcheck();
	}
	#define K_G Output[op_top++]=' '
	#define H_C Output[op_top++]='\n'
	//--------------------------------------------------------------------------------------------
	
	//--------------------------------------------------------------------------------------------
	#define ll long long
	#define uint unsigned int
	#define ull unsigned long long
	#define INV(x) ksm(x,mod-2)
	#define inf 999999999
	#define mod 998244353
	
	template<class TY>void add(TY &x,TY y){x=(x+y>=mod?x+y-mod:x+y);}
	template<class TY>void dec(TY &x,TY y){x=(x-y<0?x-y+mod:x-y);}
	template<class TY>TY add(TY x){return x>=mod?x-mod:x;}
	template<class TY>TY dec(TY x){return x<0?x+mod:0;}
	//
	int ksm(int x,int y){int re=1;for(;(y&1?re=1ll*re*x%mod:0),y;y>>=1,x=1ll*x*x%mod);return re;}
	int *fac,*inv_fac,*inv;
	void work_math(const int N)
	{
		fac=new int[N+5];inv_fac=new int[N+5];inv=new int[N+5];
		inv[1]=1;for(int i=2;i<=N;i++)inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
		fac[0]=inv_fac[0]=1;for(int i=1;i<=N;i++)fac[i]=1ll*fac[i-1]*i%mod;
		inv_fac[N]=INV(fac[N]);
		for(int i=N-1;i>=1;i--)inv_fac[i]=1ll*inv_fac[i+1]*(i+1)%mod;
	}
	int C(int x,int y){return 1ll*fac[x]*inv_fac[y]%mod*inv_fac[x-y]%mod;}
	//
	template<class TY>TY gcd(TY x,TY y){return !y?x:gcd(y,x%y);}
	template<class TY>TY exgcd(TY a,TY b,TY &x,TY &y){
		if(!b)return x=1,y=0,a;
		TY re=exgcd(b,a%b,y,x);
		return y-=a/b*x,re;
	}
	//
	template<class TY>void discretization(TY *arr,int St,int Ed){
		vector<TY>Arr;Arr.clear();
		for(int i=St;i<=Ed;i++)Arr.push_back(arr[i]);
		sort(Arr.begin(),Arr.end());
		for(int i=St;i<=Ed;i++)arr[i]=lower_bound(Arr.begin(),Arr.end(),arr[i])-Arr.begin()+1;
	}
	//-----------------------------------------------------------------------------------------------
	
	//----------------------------------------------------------------------------------------------- 
	#define maxn 510
	int n,k,a[maxn],Sum=0;
	vector<int>p;
	int Cp;
	bool cmp(int x,int y){return (x%Cp)<(y%Cp);}
	int sum[maxn];
	bool check(int x){
		int tot=0,re=0;
		Cp=x;sort(a+1,a+n+1,cmp);
		sum[n+1]=0;int st=1;
		for(int i=n;i>=1;i--){
			if(a[i]%x==0){st=i+1;break;}
			sum[i]=sum[i+1]+(x-a[i]%x);
		}
		for(int i=st;i<=n;i++){
			re+=a[i]%x;
			if(re==sum[i+1])break;
		}
		return re<=k;
	}
	
	void main()
	{
		read(n);read(k);p.clear();
		for(int i=1;i<=n;i++)read(a[i]),Sum+=a[i];
		for(int i=1;i*i<=Sum;i++)if(Sum%i==0){
			p.push_back(i);
			if(i*i!=Sum)p.push_back(Sum/i);
		}
		sort(p.begin(),p.end());
		for(int i=p.size()-1;i>=0;i--){
			if(check(p[i])){
				printf("%d",p[i]);
				return;
			}
		}
		fcheck(1);return;
	}
}

int main(){my::main();return 0;}

Measured memory_bytes: 3144