#include <bits/stdc++.h>
using namespace std;
long long ara[102];
long long dp1[102][102 * 102];
long long dp2[102][102 * 102];
long long presum[102];
long long pri[102];
long long comb1[102][102];
long long comb2[102][102];
int main() {
  for (long long i = 0; i < 102; i++) comb1[i][0] = comb2[i][0] = 1;
  for (long long i = 1; i < 102; i++) {
    for (long long j = 1; j <= i; j++)
      comb1[i][j] = (comb1[i - 1][j - 1] + comb1[i - 1][j]) % 998244353,
      comb2[i][j] = (comb2[i - 1][j - 1] + comb2[i - 1][j]) % 1000000007;
  }
  long long n;
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) scanf("%lld", ara + i);
  sort(ara + 1, ara + n + 1);
  set<int> se;
  for (long long i = 1; i <= n; i++)
    pri[ara[i]]++, presum[i] = presum[i - 1] + ara[i], se.insert(ara[i]);
  if (se.size() <= 2) {
    printf("%d\n", n);
    return 0;
  }
  dp1[0][0] = dp2[0][0] = 1;
  for (long long i = 1; i <= n; i++) {
    for (long long k = i; k; k--) {
      for (long long sum = ara[i]; sum <= presum[i]; sum++) {
        assert(k <= n && sum <= 10000);
        dp1[k][sum] += dp1[k - 1][sum - ara[i]];
        if (dp1[k][sum] >= 998244353) dp1[k][sum] -= 998244353;
        dp2[k][sum] += dp2[k - 1][sum - ara[i]];
        if (dp2[k][sum] >= 1000000007) dp2[k][sum] -= 1000000007;
      }
    }
  }
  long long ans = 0;
  for (long long i = 1; i < 102; i++) {
    if (pri[i] == 0) continue;
    for (long long k = 1; k <= pri[i]; k++) {
      long long sum = k * i;
      assert(sum <= 10000 && k <= n);
      long long x11 = dp1[k][sum];
      long long x12 = dp2[k][sum];
      long long x21 = comb1[pri[i]][k];
      long long x22 = comb2[pri[i]][k];
      assert(x11 >= 0 && x12 >= 0 && x21 >= 0 && x22 >= 0);
      if (x11 == x21 && x12 == x22) ans = max(ans, k);
    }
  }
  printf("%lld\n", ans);
  return 0;
}
