#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ii = pair<int, int>;
using lu = unsigned long long;
using l = long long;
using vs = vector<string>;
using vii = vector<ii>;
using vl = vector<l>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vvvvl = vector<vvl>;
using ll = pair<l, l>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vd = vector<double>;
using vvd = vector<vd>;
using mll = unordered_map<l, l>;
using sl = unordered_set<l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10;
const double PI = 3.14159265358979323846;
const l e0 = 1, e3 = 1000, e5 = 100000, e6 = 10 * e5, e7 = 10 * e6,
        e8 = 10 * e7, e9 = 10 * e8;
const char lf = '\n';
void solve(istream& in, ostream& out);
int main(int argc, char** argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  solve(cin, cout);
}
const l MOD = e9 + 7;
const l MAX = 101;
l dfs(l k, l sum, l p, vl& v, vvvl& dp) {
  if (k == 0) return (sum == 0) ? 1 : 0;
  if (p >= v.size()) return 0;
  l& z = dp[k][sum][p];
  if (z == -1) {
    z = dfs(k, sum, p + 1, v, dp);
    if (z == 0 and v[p] <= sum) z = dfs(k - 1, sum - v[p], p + 1, v, dp);
  }
  return z;
}
l gcd(l a, l b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
l lcm(l a, l b) { return a / (gcd(a, b)) * b; }
l sign(l n) {
  if (n < 0) return -1;
  if (n == 0) return 0;
  return 1;
}
l cong(l x, l mod) { return (x % mod + mod) % mod; }
l mult_mod(l a, l b, l mod) {
  l x = 0;
  while (b) {
    if (b % 2) x = (x + a) % mod;
    a = (a * 2) % mod;
    b /= 2;
  }
  return x;
}
l pow_mod(l base, l power, l mod) {
  l r = 1;
  while (power) {
    if (power % 2) r = mult_mod(r, base, mod);
    base = mult_mod(base, base, mod);
    power /= 2;
  }
  return r;
}
l divup(l a, l b) { return (a + b - 1) / b; }
l extended_euclid(l a, l b, l& x, l& y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  l d = extended_euclid(b, a % b, x, y);
  l t = y;
  y = x - (a / b) * y;
  x = t;
  return d;
}
l inverse_mod(l a, l n) {
  l x, y;
  l d = extended_euclid(a, n, x, y);
  if (d != 1) return 0;
  return cong(x, n);
}
l nCr(l n, l k, l mod) {
  l a = 1;
  for (l i = n; i > n - k; i--) a = mult_mod(a, i, mod);
  l b = 1;
  for (l i = l(1); i < l(k + 1); i++) b = mult_mod(b, i, mod);
  b = inverse_mod(b, mod);
  return mult_mod(a, b, mod);
}
vvl combinations(l n, l mod) {
  vvl c(n + 1, vl(n + 1));
  for (l i = l(0); i < l(n + 1); i++) {
    c[i][0] = 1;
    for (l j = l(1); j < l(i + 1); j++) {
      c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
    }
  }
  return c;
}
struct lm {
  l raw;
  lm() : raw(0) {}
  lm(l x) : raw(x) {}
  lm(lm const& x) : raw(x.raw) {}
  lm(lm&& x) { swap(*this, x); }
  friend void swap(lm& a, lm& b) { swap(a.raw, b.raw); }
  lm& operator=(l x) {
    raw = x;
    return *this;
  }
  lm& operator=(lm x) {
    swap(*this, x);
    return *this;
  }
  void operator+=(const lm x) { raw = cong(raw + x.raw, MOD); }
  lm operator+(const lm x) {
    lm z(*this);
    z += x;
    return z;
  }
  void operator-=(const lm x) { raw = cong(raw - x.raw, MOD); }
  lm operator-(const lm x) {
    lm z(*this);
    z -= x;
    return z;
  }
  void operator*=(const lm x) { raw = cong(raw * x.raw, MOD); }
  lm operator*(const lm x) {
    lm z(*this);
    z *= x;
    return z;
  }
  void operator/=(const lm x) {
    raw = cong(raw * inverse_mod(x.raw, MOD), MOD);
  }
  void operator++() { raw = cong(raw + 1, MOD); }
  void operator--() { raw = cong(raw - 1, MOD); }
  bool operator==(const lm x) { return raw == x.raw; }
  bool operator!=(const lm x) { return raw != x.raw; }
  lm operator/(const lm x) {
    lm z(*this);
    z /= x;
    return z;
  }
  lm pow(l exp) const {
    lm r(1);
    lm base(*this);
    while (exp) {
      if (exp % 2) r *= base;
      base *= base;
      exp /= 2;
    }
    return r;
  }
};
using vlm = vector<lm>;
using vvlm = vector<vlm>;
using vvvlm = vector<vvlm>;
ostream& operator<<(ostream& s, const lm& p) { return s << p.raw; }
void solve(istream& in, ostream& out) {
  l n;
  in >> n;
  vl v(n);
  for (l i = l(0); i < l(n); i++) in >> v[i];
  mll m;
  for (l x : v) m[x]++;
  l s = accumulate(begin(v), end(v), l(0));
  if (m.size() < 3) {
    cout << n << lf;
    return;
  }
  vvlm sk(n + 1, vlm(s + 1));
  sk[0][0] = 1;
  for (auto x : v) {
    for (l k = l(n) - 1; k >= l(0); k--) {
      for (l i = l(0); i < l(s + 1 - x); i++) {
        sk[k + 1][i + x] += sk[k][i];
      }
    }
  }
  l z = 1;
  vlm fact(n + 1);
  fact[0] = 1;
  for (l i = l(1); i < l(n + 1); i++) fact[i] = fact[i - 1] * i;
  for (auto xy : m) {
    l x, y;
    tie(x, y) = xy;
    for (l k = l(1); k < l(y + 1); k++) {
      l sum = k * x;
      lm t = fact[y] / fact[k] / fact[y - k];
      if (t != sk[k][sum]) break;
      z = max(z, k);
    }
  }
  out << z << lf;
}
