#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const long long inf = 0x3f3f3f3f;
long long gcd(long long x, long long y) {
  if (y == 0)
    return x;
  else
    return gcd(y, x % y);
}
long long ksm(long long a, long long b) {
  long long r = 1;
  while (b) {
    if (b & 1) r = (r * a) % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return r;
}
void exgcd(long long a, long long b, long long &x, long long &y, long long &d) {
  if (!b)
    d = a, x = 1, y = 0;
  else
    exgcd(b, a % b, y, x, d), y -= a / b * x;
}
long long inv(long long a, long long p) {
  long long x, y, d;
  exgcd(a, p, x, y, d);
  x = (x % p + p) % p;
  return x;
}
inline long long read() {
  char c = getchar();
  long long x = 0, f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
const long long maxn = 2e4 + 100;
long long dp[105][maxn], a[maxn];
struct qw {
  long long num, c;
} b[maxn];
bool cmp(long long &x, long long &y) { return x > y; }
long long c[105][105];
void init() {
  c[0][0] = 1;
  for (long long i = 1; i <= 100; i++) {
    c[i][0] = 1;
    for (long long j = 1; j <= i; j++) {
      c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
    }
  }
}
map<long long, long long> mp;
signed main() {
  long long n;
  init();
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    mp[a[i]]++;
  }
  if (mp.size() <= 2) {
    cout << n << endl;
    return 0;
  }
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 10000; j >= a[i]; j--) {
      for (long long k = 100; k >= 1; k--) {
        if (dp[k - 1][j - a[i]] == 0)
          continue;
        else {
          dp[k][j] += dp[k - 1][j - a[i]];
          dp[k][j] %= mod;
        }
      }
    }
  }
  long long ans = 0;
  for (auto it : mp) {
    long long val = it.first, num = it.second;
    for (long long k = num; k >= 0; k--) {
      if (dp[k][k * val] == 1 || dp[k][k * val] == c[num][k]) {
        ans = max(ans, k);
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
