#include <bits/stdc++.h>
using namespace std;
int arr[500], total, N, K, ans=1;
void test(int a) {
	if(a <= ans)
		return;
	int k = K;
	vector<int> v(arr, arr+N);
	sort(v.begin(), v.end(), [&](int x, int y){return x%a < y%a;});
	if(v[N-1]%a == 0) {
		ans = a;
		return;
	}
	for(int i=0, j=N-1; i<j;) {
		while(i < j && v[i] % a == 0)
			i++;
		while(i < j && v[j] % a == 0)
			j--;
		if(i >= j) break;
		int t = min(v[i]%a, a-(v[j]%a));
		v[i] -= t;
		v[j] += t;
		k -= t;
		if(k < 0)
			return;
	}
	ans = a;
}
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	cin >> N >> K;
	for(int i=0; i<N; i++) {
		cin >> arr[i];
		total += arr[i];
	}

	for(int i=1; i*i<=total; i++) {
		if(total % i)
			continue;
		test(i);
		test(total/i);
	}
	cout << ans;
}