#include <bits/stdc++.h>
using namespace std;
long long n;
const long long MAX_N = 109;
const long long MAX_S = 10009;
long long a[MAX_N];
long long dp[MAX_N][MAX_S];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  dp[0][0] = 1;
  long long cnt = 0;
  for (long long i = 1; i < n; i++) {
    if (a[i] != a[i - 1]) cnt++;
  }
  if (cnt <= 1) {
    cout << n;
    return 0;
  }
  for (long long i = 0; i < n; i++) {
    cnt = 1;
    while (i + 1 < n && a[i + 1] == a[i]) {
      cnt++;
      i++;
    }
    for (long long s = MAX_S - 1; s >= 0; s--) {
      for (long long k = n; k >= 0; k--) {
        for (long long e = 1; e <= cnt; e++) {
          if (s + e * a[i] < MAX_S && k + e <= n)
            dp[k + e][s + e * a[i]] += dp[k][s];
        }
      }
    }
  }
  long long ans = 1;
  for (long long i = 0; i < n; i++) {
    for (long long e = i; (e < n) && (a[i] == a[e]); e++) {
      long long sum = a[i] * (e - i + 1);
      if (dp[e - i + 1][sum] <= 1) ans = max(ans, e - i + 1);
    }
  }
  cout << ans;
}
