#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); vector divs; for (int i = 0; i < n; i++) { cin >> a[i]; for (long long j = 1; j * j <= a[i]; j++) { if (a[i] % j == 0) { divs.push_back(j); if (j * j != a[i]) { divs.push_back(a[i] / j); } } } } sort(divs.rbegin(), divs.rend()); divs.erase(unique(divs.begin(), divs.end()), 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; } } }