#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
      cin>>a[i];
    }

    int sum = 0;
    for (int i = 0; i < n; i++) {
      sum +=a[i];
    }

    int out = 1;
    for (int t = 2; t <= sum; t++) {
      if(sum%t) continue;

      vector<int> mod;

      int kpsum=0;
      for (int i = 0; i < n; i++) {
        mod.push_back(a[i]%t);
        kpsum += a[i]%t;
      }

      sort(mod.begin(),mod.end());
      int ith = n-kpsum/t;
      int ktry=0;
      for (int i=0; i<ith; i++) {
        ktry+=mod[i];
        if(ktry>k) break;
      }
      //cout<<ktry<<endl;
      if(ktry>k) continue;

      out = t;
    }

    cout<<out<<endl;
    return 0;
}
