#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3,sse4,mmx,popcnt")
using namespace std;
using ll = long long;
template <typename T>
struct modnum {
  using Int = typename T::type;
  using Int2 = typename T::prod_type;
  Int val;
  modnum() = default;
  modnum(const Int &_val) : val((_val % T::MOD + T::MOD) % T::MOD) {}
  modnum &operator++() {
    if (++val == T::MOD) val = 0;
    return *this;
  }
  modnum &operator--() {
    if (val-- == 0) val += T::MOD;
    return *this;
  }
  modnum &operator++(int) {
    auto ret = *this;
    ++*this;
    return ret;
  }
  modnum &operator--(int) {
    auto ret = *this;
    --*this;
    return ret;
  }
  modnum &operator+=(const modnum &o) {
    if ((val += o.val) >= T::MOD) val -= T::MOD;
    return *this;
  }
  modnum &operator-=(const modnum &o) {
    if ((val -= o.val) < 0) val += T::MOD;
    return *this;
  }
  modnum &operator*=(const modnum &o) {
    val = Int((Int2)val * o.val % T::MOD);
    return *this;
  }
  modnum &operator/=(const modnum &o) {
    *this *= o.inv();
    return *this;
  }
  friend modnum operator+(const modnum &a, const modnum &b) {
    auto ret = a;
    return ret += b;
  }
  friend modnum operator-(const modnum &a, const modnum &b) {
    auto ret = a;
    return ret -= b;
  }
  friend modnum operator*(const modnum &a, const modnum &b) {
    auto ret = a;
    return ret *= b;
  }
  friend modnum operator/(const modnum &a, const modnum &b) {
    auto ret = a;
    return ret /= b;
  }
  friend bool operator==(const modnum &a, const modnum &b) {
    return a.val == b.val;
  }
  friend bool operator!=(const modnum &a, const modnum &b) {
    return a.val != b.val;
  }
  modnum pow(ll e) const {
    modnum b = *this, a = 1;
    while (e) {
      if (e & 1) a *= b;
      b *= b;
      e >>= 1;
    }
    return a;
  }
  modnum inv() const { return pow(T::MOD - 2); }
  friend istream &operator>>(istream &is, modnum &x) {
    Int v;
    is >> v;
    x = v;
    return is;
  }
  friend ostream &operator<<(ostream &os, const modnum &x) {
    return os << x.val;
  }
};
struct _var_mod_t {
  using type = ll;
  using prod_type = __int128;
  static type MOD;
};
mt19937 rng(time(0));
typename _var_mod_t::type _var_mod_t::MOD =
    uniform_int_distribution<ll>(1e17, 1e18)(rng);
using mint = modnum<_var_mod_t>;
int main() {
  cin.tie(0)->sync_with_stdio(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int &x : a) cin >> x;
  vector<int> cnt(100 + 1);
  for (int x : a) ++cnt[x];
  int u = 0;
  for (int c : cnt) u += !!c;
  if (u <= 2) {
    cout << n << '\n';
    return 0;
  }
  vector<vector<mint>> C_(100 + 1, vector<mint>(100 + 1));
  auto C = [&](int n_, int k) -> mint {
    if (k < 0) return 0;
    if (k > n_) return 0;
    assert(n_ <= 100);
    return C_[n_][k];
  };
  C_[0][0] = 1;
  for (int n_ = 0; n_ <= 100; ++n_) {
    for (int k = 0; k <= n_; ++k) {
      if (k > 0) C_[n_][k] += C_[n_ - 1][k - 1];
      if (k < n_) C_[n_][k] += C_[n_ - 1][k];
    }
  }
  vector<vector<mint>> ways(n + 1, vector<mint>(100 * 100 + 1));
  ways[0][0] = 1;
  int ans = 1;
  for (int i = 0; i < n; ++i) {
    int x = a[i];
    for (int c = i; c >= 0; --c)
      for (int s0 = 100 * 100 - x; s0 >= 0; --s0)
        ways[c + 1][s0 + x] += ways[c][s0];
  }
  for (int x : a) {
    for (int c = ans; c <= cnt[x]; ++c) {
      mint want = C(cnt[x], c);
      if (ways[c][x * c] != want) break;
      ans = c;
    }
  }
  cout << ans << '\n';
}
