#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char c = getchar();
  int x = 0;
  bool f = 0;
  for (; !isdigit(c); c = getchar()) f ^= !(c ^ 45);
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  if (f) x = -x;
  return x;
}
struct modint {
  int x;
  modint(int o = 0) { x = o; }
  modint &operator=(int o) { return x = o, *this; }
  modint &operator+=(modint o) {
    return x = x + o.x >= 998244353 ? x + o.x - 998244353 : x + o.x, *this;
  }
  modint &operator-=(modint o) {
    return x = x - o.x < 0 ? x - o.x + 998244353 : x - o.x, *this;
  }
  modint &operator*=(modint o) { return x = 1ll * x * o.x % 998244353, *this; }
  modint &operator^=(int b) {
    modint a = *this, c = 1;
    for (; b; b >>= 1, a *= a)
      if (b & 1) c *= a;
    return x = c.x, *this;
  }
  modint &operator/=(modint o) { return *this *= o ^= 998244353 - 2; }
  modint &operator+=(int o) {
    return x = x + o >= 998244353 ? x + o - 998244353 : x + o, *this;
  }
  modint &operator-=(int o) {
    return x = x - o < 0 ? x - o + 998244353 : x - o, *this;
  }
  modint &operator*=(int o) { return x = 1ll * x * o % 998244353, *this; }
  modint &operator/=(int o) { return *this *= ((modint(o)) ^= 998244353 - 2); }
  template <class I>
  friend modint operator+(modint a, I b) {
    return a += b;
  }
  template <class I>
  friend modint operator-(modint a, I b) {
    return a -= b;
  }
  template <class I>
  friend modint operator*(modint a, I b) {
    return a *= b;
  }
  template <class I>
  friend modint operator/(modint a, I b) {
    return a /= b;
  }
  friend modint operator^(modint a, int b) { return a ^= b; }
  friend bool operator==(modint a, int b) { return a.x == b; }
  friend bool operator!=(modint a, int b) { return a.x != b; }
  bool operator!() { return !x; }
  modint operator-() { return x ? 998244353 - x : 0; }
};
int n, a[105], cnt[105];
modint f[105][10005], g[105][10005];
modint fac[233], ifac[233];
inline void pre(int n) {
  fac[0] = ifac[0] = 1;
  for (register int i = (1); i <= (n); ++i)
    fac[i] = fac[i - 1] * i, ifac[i] = ifac[i - 1] / i;
}
inline modint C(int n, int m) { return fac[n] * ifac[m] * ifac[n - m]; }
signed main() {
  pre(103);
  f[0][0] = 1;
  n = read();
  for (register int i = (1); i <= (n); ++i) {
    a[i] = read(), cnt[a[i]]++;
    for (register int j = (i); j >= (1); --j)
      for (register int k = (10000); k >= (a[i]); --k)
        f[j][k] += f[j - 1][k - a[i]];
  }
  int orz = 0;
  for (register int i = (1); i <= (100); ++i) orz += (cnt[i] > 0);
  int res = 0;
  for (register int i = (1); i <= (100); ++i)
    for (register int j = (1); j <= (cnt[i]); ++j)
      if (C(cnt[i], j).x == f[j][j * i].x) res = max(res, j);
  if (orz == 1) res = n;
  if (orz == 2) {
    vector<int> o;
    for (register int i = (1); i <= (100); ++i)
      if (cnt[i]) o.push_back(cnt[i]);
    if (res == o[0] || res == o[1]) res = n;
  }
  cout << res;
  return 0;
}
