#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
bool ok (int d, const vector<int>& a, int k) {
  vector<int> rem;
  int inc = 0;
  for (int i : a) {
    rem.push_back(i % d);
    inc += d - i % d;
  }
  sort(rem.begin(), rem.end());
  int dec = 0;
  for (int i : rem) {
    dec += i;
    inc -= d - i;
    if (dec == inc && inc <= k) return true;
  } 
  return false;
}
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  int ans = 0;
  for (int i = 1; i * i <= sum; i++) {
    if (sum % i) continue;
    if (ok(i, a, k)) ans = max(ans, i);
    if (ok(sum / i, a, k)) ans = max(ans, sum / i);
  }
  cout << ans << endl;
  return 0;
}