#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
long long mexp(long long a, long long b) {
  long long ans = 1;
  a %= mod;
  while (b) {
    if (b & 1) ans = (ans * a) % mod;
    b >>= 1;
    a = (a * a) % mod;
  }
  return ans;
}
int a[101];
int cnt[101];
int pre[101];
int dp[101][10001];
long long fac[101], inv[101];
void calc() {
  fac[0] = fac[1] = 1;
  for (long long i = 2; i <= 100; ++i) {
    fac[i] = (fac[i - 1] * i) % mod;
  }
  inv[0] = 1;
  for (long long i = 1; i <= 100; ++i) {
    inv[i] = mexp(fac[i], mod - 2);
  }
}
long long nCr(long long n, long long r) {
  return (((fac[n] * inv[r]) % mod) * inv[n - r]) % mod;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  calc();
  int n;
  cin >> n;
  for (long long i = 1; i <= n; ++i) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  sort(a + 1, a + n + 1);
  for (long long i = 1; i <= n; ++i) {
    pre[i] = pre[i - 1] + a[i];
  }
  int c = 0;
  for (long long i = 1; i <= 100; ++i) {
    c += (cnt[i] > 0);
  }
  if (c <= 2) {
    cout << n;
    return 0;
  }
  dp[0][0] = 1;
  for (long long i = 1; i <= n; ++i) {
    for (long long j = i; j >= 1; --j) {
      for (long long x = pre[i]; x >= a[i]; --x) {
        dp[j][x] += dp[j - 1][x - a[i]];
        if (dp[j][x] >= mod) dp[j][x] -= mod;
      }
    }
  }
  int ans = 0;
  for (long long i = 1; i <= 100; ++i) {
    for (long long j = 1; j <= cnt[i]; ++j) {
      if (dp[j][j * i] == nCr(cnt[i], j)) ans = max(ans, (int)j);
    }
  }
  cout << ans;
  return 0;
}
