#include <iostream>
#include <cmath>
#include <algorithm>
#include <set>
using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	int* A = new int[N];
	long long sum = 0;
	for (int n = 0; n < N; n++) {
		cin >> A[n];
		sum += A[n];
	}
	set<long long> candidates;

	for (long long i = 1; i * i <= sum; i++) {
		if (sum % i == 0) {
			candidates.insert(i);
			candidates.insert(sum/i);
		}
	}
	long long ans = 1;
	for (long long x : candidates) {
		long long need = 0;

		long long* r = new long long[N];
		for (int n = 0; n < N; n++) r[n] = A[n] % x;
		sort(&(r[0]), &(r[N]));
		long long tot = 0;
		for (int n = 0; n < N; n++) tot += r[n];
		int l = N - tot / x;
		need = 0;
		for (int i = 0; i < l; i++) need += r[i];
		if (need <= K) ans = max(ans, x);
	}
	cout << ans << endl;
}