#include <bits/stdc++.h>
using namespace std;
// define
#define endl "\n"
#ifdef LOCAL
#define lout cerr
#else
ostream devnull(0);
#define lout devnull
#endif
#define AMULET \
  cin.tie(0);  \
  ios::sync_with_stdio(false);
// https://github.com/kurokoji/.cpp-Template/blob/master/template/template2.cpp
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...)                                 \
  GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1) \
  (__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, d) rep5(i, a, n, d, <)
#define rep5(i, a, n, d, o) for (auto i = decltype(n)(a), _n = (n); i o _n; i += (d))

#define rrep(...)                                    \
  GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1) \
  (__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, -1)
#define rrep4(i, a, n, d) rep5(i, (a)-1, n, d, >=)

#define repc(...)                                    \
  GET_MACRO(__VA_ARGS__, repc4, repc3, repc2, repc1) \
  (__VA_ARGS__)
#define repc1(n) repc2(_, n)
#define repc2(i, n) repc3(i, 0, n)
#define repc3(i, a, n) repc4(i, a, n, 1)
#define repc4(i, a, n, d) rep5(i, a, n, d, <=)

#define dump(x) lout << #x << " = " << x << endl;
// alias
typedef long long ll;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
// func
template <class C>
inline void vcin(C &c);
template <class C, class D>
inline void vcin(C &c, D &d);
template <class C>
inline void vcout(const C &c, const string separate = "\n");
template <class T = int>
inline T in();

void solve()
{
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vcin(a);

  lint sum = accumulate(a.begin(), a.end(), 0LL);

  dump(sum);

  vector<lint> ds;

  repc(i, 1, (int)sqrt(sum) + 1)
  {
    if (sum % i == 0){
      ds.push_back(sum/i);
      ds.push_back(i);
    }
  }
  sort(ds.rbegin(),ds.rend());
  //vcout(ds);

  for(auto&& d:ds)
  {
    lout << endl;

    dump(d);

    if (sum % d != 0)
      continue;

    vector<int> r(n);

    rep(i, n)
    {
      r[i] = a[i] % d;
    }
    sort(r.begin(), r.end());

    vector<lint> na(n), pa(n);
    rep(i, n)
    {
      na[i] = r[i];
      pa[i] = d - r[i];
    }
    rep(i, n - 1)
    {
      na[i + 1] += na[i];
      pa[i + 1] += pa[i];
    }

    // vcout(na," ");
    // cout << endl;
    // vcout(pa," ");
    // cout << endl;

    rep(i, n)
    {
      lint ncnt = na[i];
      lint pcnt = pa[n - 1] - pa[i];
      if (ncnt == pcnt && pcnt <= k)
      {
        cout << d << endl;
        return;
      }
    }
  }
}

signed main()
{
  AMULET
  solve();
  return 0;
}

template <class C>
inline void vcin(C &c)
{
  for (auto &a : c)
  {
    cin >> a;
  }
}
template <class C, class D>
inline void vcin(C &c, D &d)
{
  for (auto it1 = c.begin(), it2 = d.begin(); it1 != c.end() && it2 != d.end(); it1++, it2++)
  {
    cin >> *it1 >> *it2;
  }
}
template <class C>
inline void vcout(const C &c, const string separate)
{
  for (auto it = c.begin(); it != c.end(); it++)
  {
    if (it != c.begin())
      cout << separate;
    cout << *it;
  }
}
template <class T = int>
inline T in()
{
  T x;
  cin >> x;
  return (x);
}


Measured memory_bytes: 256