#include <bits/stdc++.h>
using namespace std;
const long long N = 105, MOD = 1e9 + 7;
long long dp[N * N][N], fact[N];
map<long long, long long> m;
void init() {
  fact[0] = 1;
  for (long long i = 1; i < N; i++) fact[i] = fact[i - 1] * i % MOD;
}
long long fastpow(long long n, long long p) {
  long long res = 1;
  while (p) {
    if (p & 1) res = res * n % MOD;
    n = n * n % MOD;
    p >>= 1;
  }
  return res;
}
long long nCr(long long n, long long r) {
  return fact[n] * fastpow(fact[r], MOD - 2) % MOD *
         fastpow(fact[n - r], MOD - 2) % MOD;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  init();
  long long n;
  cin >> n;
  long long arr[n + 1];
  for (long long i = 1; i <= n; i++) {
    cin >> arr[i];
    m[arr[i]]++;
  }
  if (m.size() <= 2) {
    cout << n << "\n";
    return 0;
  }
  dp[0][0] = 1;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 10000; j >= arr[i]; j--) {
      for (long long k = 1; k <= i; k++) {
        if (dp[j - arr[i]][k - 1]) {
          dp[j][k] += dp[j - arr[i]][k - 1];
        }
      }
    }
  }
  long long ans = 0;
  for (auto [a, b] : m) {
    for (long long i = 1; i <= b; i++) {
      if (dp[a * i][i] == nCr(b, i)) ans = max(i, ans);
    }
  }
  cout << ans << "\n";
}
