#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
template<class S, class T> inline S min_L(S a,T b){
  return a<=b?a:b;
}
template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){
  static int skip[16]={0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  (*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );
  (*arr)=(T*)(*mem);
  (*mem)=((*arr)+x);
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class T> int Factor_L(T N, T fac[], int fs[]){
  T i;
  int sz=0;
  if(N%2==0){
    fac[sz] = 2;
    fs[sz] = 1;
    N /= 2;
    while(N%2==0){
      N /= 2;
      fs[sz]++;
    }
    sz++;
  }
  for(i=3;i*i<=N;i+=2){
    if(N%i==0){
      fac[sz] = i;
      fs[sz] = 1;
      N /= i;
      while(N%i==0){
        N /= i;
        fs[sz]++;
      }
      sz++;
    }
  }
  if(N > 1){
    fac[sz] = N;
    fs[sz] = 1;
    sz++;
  }
  return sz;
}
template<class T> int Divisor_L(T N, T res[], void *mem = wmem){
  T *fc;
  int *fs, fsz, i, j, k, s, sz=0;
  walloc1d(&fc, 100, &mem);
  walloc1d(&fs, 100, &mem);
  fsz =Factor_L(N, fc, fs);
  res[sz++] = 1;
  for(i=0;i<(fsz);i++){
    s = sz;
    k = s * fs[i];
    for(j=0;j<(k);j++){
      res[sz++] = res[j] * fc[i];
    }
  }
  sort(res, res+sz);
  return sz;
}
char memarr[96000000];
int N;
int K;
int A[500];
int b[500];
int s;
int ys;
int y[10000];
int main(){
  int i, j, k, m, res;
  long long cur, nd;
  wmem = memarr;
  rd(N);
  rd(K);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  {
    int KL2GvlyY, Q5VJL1cS;
    if(N==0){
      Q5VJL1cS = 0;
    }
    else{
      Q5VJL1cS = A[0];
      for(KL2GvlyY=(1);KL2GvlyY<(N);KL2GvlyY++){
        Q5VJL1cS += A[KL2GvlyY];
      }
    }
    s =Q5VJL1cS;
  }
  ys =Divisor_L(s, y);
  for(m=0;m<(ys);m++){
    for(i=0;i<(N);i++){
      b[i] = A[i] % y[m];
    }
    sort(b, b+N);
    nd = cur = 0;
    j = 0;
    for(i=N-1;i>=0;i--){
      if(b[i]==0){
        break;
      }
      nd += y[m] - b[i];
      cur += y[m] - b[i];
      b[i] = 0;
      while(cur > 0 && j<i){
        k =min_L(cur, b[j]);
        b[j] -= k;
        cur -= k;
        if(b[j]==0){
          j++;
        }
      }
    }
    if(nd <= K){
      res = y[m];
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190822-2

// --- original code ---
// int N, K, A[500];
// 
// int b[500];
// int s;
// int ys, y[10000];
// {
//   int i, j, k, m, res;
//   ll nd, cur;
// 
//   rd(N,K,A(N));
//   s = sum(A(N));
//   ys = Divisor(s, y);
// 
//   rep(m,ys){
//     rep(i,N) b[i] = A[i] % y[m];
//     sort(b, b+N);
//     nd = cur = 0;
//     j = 0;
//     for(i=N-1;i>=0;i--){
//       if(b[i]==0) break;
//       nd += y[m] - b[i];
//       cur += y[m] - b[i];
//       b[i] = 0;
//       while(cur > 0 && j<i){
//         k = min(cur, b[j]);
//         b[j] -= k;
//         cur -= k;
//         if(b[j]==0) j++;
//       }
//     }
//     if(nd <= K) res = y[m];
//   }
// 
//   wt(res);
// }


Measured memory_bytes: 256