#include #include using namespace std; using namespace atcoder; struct Fast { Fast() { std::cin.tie(nullptr); ios::sync_with_stdio(false); cout << setprecision(10); } } fast; #define all(a) (a).begin(), (a).end() #define contains(a, x) ((a).find(x) != (a).end()) #define rep(i, a, b) for (int i = (a); i < (int)(b); i++) #define rrep(i, a, b) for (int i = (int)(b)-1; i >= (a); i--) #define YN(b) cout << ((b) ? "YES" : "NO") << "\n"; #define Yn(b) cout << ((b) ? "Yes" : "No") << "\n"; #define yn(b) cout << ((b) ? "yes" : "no") << "\n"; template ostream& operator<<(ostream& os, vector& vec) { for (int i = 0; i < vec.size(); i++) { os << vec[i] << (i + 1 == vec.size() ? "" : " "); } return os; } using ll = long long; using vb = vector; using vvb = vector; using vi = vector; using vvi = vector; using vl = vector; using vvl = vector; using mint = modint998244353; using vm = vector; using vvm = vector; inline ostream& operator<<(ostream& os, const mint P) { return os << P.val(); }; void solve() { int n, k; cin >> n >> k; vl a(n); rep(i, 0, n) cin >> a[i]; ll ans = 1; for (ll g = 2; g <= 1e6; g++) { ll c = 0; rep(i, 0, n) { ll v = a[i] / g * g; c += min(a[i] - v, v + g - a[i]); } if (c <= k) ans = g; } rep(i, 0, n) rep(j, -k, k + 1) { if (a[i] + j <= 0) continue; ll g = a[i] + j; ll c = 0; rep(i, 0, n) { ll v = a[i] / g * g; c += min(a[i] - v, v + g - a[i]); } if (c <= k) ans = max(ans, g); } cout << ans << "\n"; } int main() { int t = 1; // cin >> t; while (t--) solve(); }