#include <bits/stdc++.h>
using namespace std;
const long long N = 10001, K = 101, mod = 1e9 + 7;
long long dp[N][K], fact[K];
long long binpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return res;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  fact[0] = 1;
  for (long long i = 1; i < K; ++i) fact[i] = (fact[i - 1] * i) % mod;
  map<long long, long long> m;
  long long n;
  cin >> n;
  vector<long long> a(n + 1);
  for (long long i = 1; i <= n; ++i) cin >> a[i], m[a[i]]++;
  dp[0][0] = 1;
  for (long long i = 1; i <= n; ++i)
    for (long long j = n; j >= 1; --j)
      for (long long k = N - 1; k >= a[i]; --k) {
        dp[k][j] += dp[k - a[i]][j - 1];
        if (dp[k][j] > mod) dp[k][j] %= mod;
      }
  long long ans = 0;
  for (auto it : m) {
    long long p = it.first, cnt = it.second;
    for (long long j = 1; j <= cnt; ++j) {
      long long tot = (fact[cnt] * ((binpow(fact[cnt - j], mod - 2, mod) *
                                     binpow(fact[j], mod - 2, mod)) %
                                    mod)) %
                      mod;
      if (tot == dp[p * j][j]) ans = max(ans, j);
    }
  }
  if (m.size() == 2)
    cout << n << "\n";
  else
    cout << ans << "\n";
}
