#include using namespace std; void fast_io() { ios::sync_with_stdio(false); std::cin.tie(nullptr); } int main() { fast_io(); int n, k; cin >> n >> k; vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a.rbegin(), a.rend()); long long ans = 1; vector divs; if (a[0] > k) { for (long long a0 = a[0] - k; a0 <= a[0] + k; a0++) { for (long long i = 1; i * i <= a0; i++) { if (a0 % i == 0) { divs.push_back(i); if (i * i != a0) { divs.push_back(a0 / i); } } } } } else { long long su = 0; for (int i = 0; i < n; i++) { su += a[i]; } for (long long a0 = su - k; a0 <= su + k; a0++) { for (long long i = 1; i * i <= a0; i++) { if (a0 % i == 0) { divs.push_back(i); if (i * i != a0) { divs.push_back(a0 / i); } } } } } sort(divs.begin(), divs.end()); divs.erase(unique(divs.begin(), divs.end()), divs.end()); reverse(divs.begin(), divs.end()); for (long long d : divs) { long long need = 0; for (int i = 0; i < n; i++) { need += min(a[i] % d, d - a[i] % d); } if (need <= k) { cout << d << endl; return 0; } } }