#include "bits/stdc++.h"

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define DOUBLE fixed << setprecision(10)
#define fi first
#define se second
const double pi = acos(-1.0);
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };
template <typename T>
bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
};
template <typename T>
bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
};
void Pvll(vll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) cout << v[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}
void Pvvll(vvll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) {
		rep(j, v[i].size()) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Ps(string s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) cout << s[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}

void Pvs(vs s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) {
		rep(j, s[i].size()) {
			cout << s[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}

void Yay(bool x) {
	if (x) cout << "Yay!\n";
	else cout << ":(\n";
}

//最大公約数
ll gcd(ll m, ll n) {
	if ((0 == m) || (0 == n))
		return 0;

	// ユークリッドの方法
	while (m != n)
	{
		if (m > n) m = m - n;
		else         n = n - m;
	}
	return m;
}
//最小公倍数
ll lcm(ll m, ll n) {
	if ((0 == m) || (0 == n))
		return 0;

	return (m * n / gcd(m, n));
}

ll  n, m, r, l, k, h, ans = 0, ret = M;
bool flag = false, flag2 = false, flag3 = false;
string s,t;

void INIT() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << DOUBLE;
}
vll enum_div(ll n)//nの約数を列挙
{
	vll w;
	for (int i = 1; i*i <= n; ++i)
	{
		if (n%i == 0)
		{
			w.push_back(i);
			//cout << i << endl;
			if (i != 1 && i*i != n)
			{
				w.push_back(n / i);
				//cout << n/i << endl;
			}
		}
	}
	w.pb(n);
	return w;
}

int main() {
	INIT();
	cin >> n >> k;
	vll w(n);
	ret = 0;
	rep(i, n) {
		cin >> w[i];
		ret += w[i];
	}
	vll v = enum_div(ret);
	sort(reall(v));
	//Pvll(v);
	for (auto p : v) {
		ans = 0, ret = 0;
		vll x(n+1,0),y(n+1,0);
		rep(i, n) {
			x[i+1] = w[i] % p;
			y[i] = p - w[i] % p;
		}
		sort(all(x));
		sort(reall(y));
		rep(i, n) x[i + 1] += x[i];
		repr(i, n) y[i] += y[i + 1];
		//Pvll(x);
		//Pvll(y);
		rep(i,n+1) if(x[i] <= k && y[i] <= k){
			cout << p << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256