/* 

 */
/* ID: thanhvq1
LANG: C++14
PROB: namenum
*/

#pragma GCC optimize ("O2")
#include<bits/stdc++.h>
#include<unistd.h>
using namespace std;

// defines
//#define int long long
typedef long long ll;
#define double long double
#define vec vector
#define vi vector<int>
#define vvi vector<vector<int>>
#define FZ(n) memset((n),0,sizeof())
#define FMO(n) memset((n),-1,sizeof(n))
#define unset unordered_set
#define ii pair<int, int>
#define vii vector<ii>
#define F first
#define S second
#define mp make_pair
#define PB push_back
#define ALL(x) begin(x),end(x)
#define SZ(x) ((int)(x).size())
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define bitcount(n) __builtin_popcountll(n)
#define reset(x, y) memset(x, y, sizeof(x))
#define uni(x) (x).erase(unique(all(x)), (x).end());
#define debug(x) cout << #x << " = " << (x) << endl
#define debug2(x, y) cout<<#x<<" = "<<(x)<<", "<<#y<<" = "<<(y)<< endl
#define debug3(x, y, z) cout<<#x<<" = "<<(x)<<", "<<#y<<" = "<<(y)<<", "<<#z<<" = "<<(z)<<endl
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)
#define max3(a, b, c) max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c) min(a, b) < min(b, c) ? min(a, b) : min(b, c)

//permanent constants
const long long INF64 = 1e18; const int INF32 = 1e9; const int BIG = (int)(1e9 + 239);
const int MOD = 998244353; //1e9 + 7;  const ll MOD2 = (ll)MOD * (ll)MOD;
const double PI = 2.0*acos(0.0); //acos(-1.0L);
const double EPS = static_cast<double>(1e-10);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int dx[4] = {0, 1, 0, -1}; const int dy[4] = {1, 0, -1, 0};
//const ll INF = (ll)(1e18 + 239);

//random
mt19937 rnd(239); //(chrono::high_resolution_clock::now().time_since_epoch().count());

void FILEIO() {  freopen("in.txt", "r", stdin);  freopen("out.txt", "w", stdout); }
//void FILEIO()   {freopen("in.txt", "w", stdout);}
//void FILEIO() {  freopen("namenum.in", "r", stdin);  freopen("namenum.out", "w", stdout); }
void input() {   }

int cost[10][10][10][10]; // cost[s][k][x][y] = min cost to get k from s, with counter x - y 


// A O(sqrt(n)) program that prints all divisors in sorted order 
// #include <bits/stdc++.h> 
// using namespace std; 

vector<int> calcDivisors(int n) { // function to print the divisors 
    vector<int> v1, v2; // v2 - vector to store half of the divisors
    for (int i=1; i<=sqrt(n); i++) { 
        if (n%i==0) { 
	    v1.push_back(i); 
            if(n/i!=i) v2.push_back(n/i); // if not equal: push the second divisor in v2
        } 
    }
    for (int i=v2.size()-1; i>=0; i--) v1.push_back(v2[i]);// v2 push back to v1 in reverse
    return v1;
} 
  
void solve() {
	int n, k; cin >> n >> k;
	vi a(n); FOR(i, 0, n) cin >> a[i];
	int sum = 0; FOR(i, 0, n) sum += a[i];
	vi div = calcDivisors(sum); reverse(ALL(div));
	FOR(i, 0, SZ(div)) {
		int d = div[i];
		
//		debug2(sum, d);
		
		vi sodu(n);
		FOR(i, 0, n) sodu[i] = (a[i]%d+d)%d; // sodu[i] >= 0
		int z = 0;
		sort(ALL(sodu));
		
//		FOR(i, 0, n) cout << sodu[i] << ", "; cout << endl;
		
		int st=0, ed = SZ(sodu)-1;
		while(st<ed) {
			int mn = min(sodu[st], d-sodu[ed]);
			
//			debug3(sodu[st], sodu[ed], mn );
			
			z += mn;
			sodu[st] -= mn, sodu[ed] = (sodu[ed]+mn)%d;
			
//			debug3(z, sodu[st], sodu[ed]);
			
			if(sodu[st]==0) st++; if(sodu[ed]==0) ed--;
			
//			debug2(st, ed);
			
		}
		if(z<=k) {cout<<d<< endl; return;}
	}
}

signed main() {
  ios_base::sync_with_stdio(false); cin.tie();
//  FILEIO();
//auto beginProgram = chrono::steady_clock::now();

//	int const T=10, N = 100000;
//	cout << T << endl;
//	FOR(i, 0, T) {
//		cout << N << endl;
//		FOR(i, 0, N) cout << "0 " ;
//		cout << endl;
//	}

//  int test = 0;
//  int t; cin >> t;
//  while(t--)
  {
//	  cout << "Case " << ++test << ": ";
	  solve();
  }

//  auto endProgram = chrono::steady_clock::now();
//  cout << chrono::duration_cast<chrono::milliseconds>(endProgram - beginProgram).count() << " ms" << endl;

  return 0;
}



Measured memory_bytes: 256