#define _USE_MATH_DEFINES
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include<iostream>
#include<unordered_set>

using namespace std;

#define dprint(Exp,...) if(Exp){fprintf(stderr, __VA_ARGS__);}
#define printe(...) fprintf(stderr, __VA_ARGS__);
//#define printe(...) void();
#define printE(...) fprintf(stderr, __VA_ARGS__);
//#define printE(...) void();


#define PrtExp(_Exp)  cerr<< #_Exp <<" = "<< (_Exp)
#define PrtExpN(_Exp)  cerr<< #_Exp <<" = "<< (_Exp) <<"\n"

#define SINT(n) scanf("%d",&n)
#define SINT2(n,m) scanf("%d %d",&n,&m)
#define SINT3(n,m,o) scanf("%d %d %d",&n,&m,&o)
#define SINT4(n,m,o,P) scanf("%d %d %d %d",&n,&m,&o,&P)
#define SINT5(n,m,o,P,q) scanf("%d %d %d %d %d",&n,&m,&o,&P,&q)
#define SLL(n) scanf("%lld",&n)
#define SLL2(n,m) scanf("%lld %lld",&n,&m)
#define SLL3(n,m,o) scanf("%lld %lld %lld",&n,&m,&o)
#define SST(s) scanf("%s",s)
#define SCH(c) scanf("%c",&c)

#define GC() getchar()

#define PINT(n) printf("%d",(int)(n))
#define PINT2(n,m) printf("%d %d",(int)(n),(int)(m))
#define PINT3(n,m,l) printf("%d %d %d",(int)(n),(int)(m),(int)(l))
#define PLL(n) printf("%lld",(long long)(n))
#define PST(s) printf("%s",(s))
#define PCH(s) printf("%c",(s))

#define PINTN(n) printf("%d\n",(int)(n))
#define PINT2N(n,m) printf("%d %d\n",(int)(n),(int)(m))
#define PINT3N(n,m,l) printf("%d %d %d\n",(int)(n),(int)(m),(int)(l))
#define PLLN(n) printf("%lld\n",(long long)(n))
#define PSTN(s) printf("%s\n",(s))
#define PCHN(s) printf("%c\n",(s))

#define PSP() printf(" ")
#define PN() printf("\n")

#define PC(c) putchar(c)
#define CSP (' ')
#define SN ("\n")

#define rep(i,a) for(int i=0;i<a;i++)
#define reP(i,a) for(int i=0;i<=a;i++)
#define Rep(i,a) for(int i=a-1;i>=0;i--)
#define ReP(i,a) for(int i=a;i>=0;i--)

#define rEp(i,a) for(i=0;i<a;i++)
#define rEP(i,a) for(i=0;i<=a;i++)
#define REp(i,a) for(i=a-1;i>=0;i--)
#define REP(i,a) for(i=a;i>=0;i--)

#define repft(i,a,b) for(int i=a;i<b;i++)
#define repfT(i,a,b) for(int i=a;i<=b;i++)
#define Repft(i,a,b) for(int i=a-1;i>=b;i--)
#define RepfT(i,a,b) for(int i=a;i>=b;i--)

#define foreach(a,it) for(auto it = a.begin(); it != a.end(); ++it)

#define FILL(a,v) fill(begin(a),end(a), v)
#define FILL0(a) memset(a,0,sizeof(a))
#define FILL1(a) memset(a,-1,sizeof(a))

typedef long long ll;

typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll>   Pll;


const int INF = 1'010'000'000; // 0x3C33'6080
const ll INFLL = 0x1f1f1f1f1f1f1f1fLL;//2,242,545,357,980,376,863

template <class A, class B> inline ostream& operator<<(ostream& st, const pair<A, B>& P) { return st << "(" << P.first << "," << P.second << ")"; };
template <class A, class B> inline pair<A, B> operator+(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first + Q.first, P.second + Q.second); };
template <class A, class B> inline pair<A, B> operator-(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first - Q.first, P.second - Q.second); };

#define fs  first
#define sc  second

int bitCount(unsigned int bits) {
	bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);    //  2bitごとに計算
	bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);    //  4bitごとに計算
	bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);    //  8bitごとに計算
	bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);    //  16ビットごとに計算   
	return (bits & 0x0000ffff) + (bits >> 16);    //  32ビット分を計算   
}

int n;
ll a[502];
ll k;


const int PN = 100000;
int isPrime[PN + 5]; // 0:prime

vector<int> p; // 素数
vector<int> q; // 上限

ll ans = 0;
/*
40
   1  7  5  6  8  2  6  5
   0  8  8  8  8  0  8  8
   -1 +1 +3 +2 0  -2 +2 +3
L                 4     2
R  6  6  2  4
r 14
d +8

*/
void solve(ll x) {
	if (x <= ans) return;

	ll r = 0;
	ll d = 0;
	vector<ll> H;
	vector<ll> L;
	rep(i, n) {
		ll lo = a[i] / x * x;
		ll hi = (a[i] + x - 1) / x * x;
		ll ld = abs(a[i] - lo);
		ll hd = abs(a[i] - hi);
		if (ld < hd) {
			r += ld;
			d -= ld;
			L.push_back(hd - ld);
		} else {
			r += hd;
			d += hd;
			if (ld != hd) {
				H.push_back(ld - hd);
			}
		}
	}
	//cout << "" << x << "  r:" << r << "  d:" << d << endl;

	if (d < 0) {
		sort(L.begin(), L.end());
		rep(i, L.size()) {
			d += x;
			r += L[i];
			if (d == 0) break;
		}
	} else if(d > 0){
		sort(H.begin(), H.end());
		rep(i, H.size()) {
			d -= x;
			r += H[i];
			if (d == 0) break;
		}
	}
	//cout << "#   " << x << "  r:" << r << endl << endl;
	//cout << "r:" << r << endl << endl;
	if (r <= k * 2) {
		ans = max(ans, x);
	}
}

void dfs(int i, ll x) {
	if (i == p.size()) {
		solve(x);
		return;
	}
	reP(j, q[i]) {
		dfs(i + 1, x);
		x *= p[i];
	}
}

int main() {
	for (int i = 2; i < PN; ++i) {
		if (isPrime[i] > 0) continue;
		for (int j = i + i; j < PN; j += i) {
			isPrime[j] = i;
		}
	}
	cin >> n >> k;
	ll s = 0;
	rep(i, n) {
		cin >> a[i];
		s += a[i];
	}
	map<int,int> insu;
	for (int i = 2; i < PN; ++i) {
		if (isPrime[i] > 0) continue;
		for (;;) {
			if (s % i == 0) {
				s /= i;
				insu[i]++;
			} else {
				break;
			}
		}
	}
	if (s > 1) {
		insu[s] = 1;
	}
	for (auto&x : insu) {
		// cout << x << endl;
		p.push_back(x.first);
		q.push_back(x.second);
	}
	dfs(0, 1);
	cout << ans << endl;

}

/*
5e8

40
1 7 5 6 8 2 6 5
0 8 8 8 8 0 8 8

-1
+1
+3
+2
0
-2
+2
+3
sum:0
abssum:14


-1
+1
+3
+2
0
-2
+2
-5
sum:0
abssum:16


*/

Measured memory_bytes: 640