#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define int long long
#define mod 1000000007
using namespace std;
int n, k, a[600], sum, ans;
bool f(int p) {
	vector<int>v; int cnt = 0;
	for (int i = 0; i < n; i++) {
		v.push_back(a[i] % p);
		cnt += a[i] % p;
	}
	sort(v.begin(), v.end());
	int c1 = 0;
	for (int i = 0; i < v.size() - cnt / p; i++)c1 += v[i];
	return c1 <= k;
}
signed main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i]; sum += a[i];
	}
	for (int i = 1; i*i <= sum; i++) {
		if (sum%i == 0) {
			if (f(i))ans = i;
			if (f(sum / i)) {
				cout << sum / i << endl;
				return 0;
			}
		}
	}
	cout << ans << endl;
}