#include<bits/stdc++.h>
using namespace std;
const int N=505;
int n,k,sum,a[N],b[N],l[N],r[N];
bool judge(int m)
{
    int ans=0,tot=0;
    for(int i=1;i<=n;i++)
        b[i]=a[i]%m;
    sort(b+1,b+1+n);
    for(int i=1;i<=n;i++)
        l[i]=l[i-1]+b[i];
    for(int i=n;i>=1;i--)
        r[i]=r[i+1]+(m-b[i]);
    for(int i=1;i<n;i++)
        if(l[i]==r[i+1]&&l[i]<=k) return true;
    return false;
}
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]),sum+=a[i];
    int ans=1;
    for(int i=1;i*i<=sum;i++)
        if(sum%i==0)
    {
        if(judge(i))
            ans=max(ans,i);
        if(judge(sum/i))
            ans=max(ans,sum/i);
    }
    printf("%d\n",ans);
}
