#include <bits/stdc++.h>
using namespace std;
long long int inf = 1e14;
int mod = 998244353;
char en = '\n';
long long int abs1(long long int x) {
  if (x < 0) return -x;
  return x;
}
long long int power(long long int x, long long int n, long long int mod) {
  long long int res = 1;
  while (n) {
    if (n & 1) res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}
long long int arr[101];
int dp[2][101][101 * 101];
long long int nCr[101][101];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  memset(nCr, 0, sizeof(nCr));
  nCr[0][0] = 1;
  for (long long int i = 1; i < 101; i++) {
    for (long long int j = 0; j <= i; j++) {
      if (j == 0 or j == i)
        nCr[i][j] = 1;
      else
        nCr[i][j] = (nCr[i - 1][j - 1] + nCr[i - 1][j]) % mod;
    }
  }
  map<long long int, long long int> par;
  long long int n;
  cin >> n;
  for (long long int i = 1; i <= n; i++) {
    cin >> arr[i];
    par[arr[i]]++;
  }
  memset(dp, 0, sizeof(dp));
  dp[0][0][0] = 1;
  for (long long int i = 1; i <= n; i++) {
    long long int curr = i & 1;
    long long int curr2 = (i - 1) & 1;
    for (long long int k = 0; k < 101; k++) {
      for (long long int p = 0; p <= i * 100; p++) dp[curr][k][p] = 0;
    }
    for (long long int k = 0; k <= i; k++) {
      for (long long int sum1 = 0; sum1 <= i * 100; sum1++) {
        dp[curr][k][sum1] = dp[curr2][k][sum1];
        if (arr[i] <= sum1 && k != 0)
          dp[curr][k][sum1] += dp[curr2][k - 1][sum1 - arr[i]];
        if (dp[curr][k][sum1] >= mod) dp[curr][k][sum1] -= mod;
      }
    }
  }
  long long int res = 0;
  for (auto it : par) {
    long long int count = it.second;
    for (long long int ct = 1; ct <= count; ct++) {
      long long int val = it.first * ct;
      if (dp[n & 1][ct][val] == nCr[count][ct]) res = max(res, ct);
    }
  }
  if (par.size() == 2) {
    if (res == par.begin()->second or res == (n - par.begin()->second)) {
      cout << n << en;
      return 0;
    }
  }
  cout << res << en;
  return 0;
}
