#include <bits/stdc++.h>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
long long int myRand(long long int B) { return (unsigned long long)rng() % B; }
int dp[10001][102];
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> s;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    s[a[i]]++;
  }
  if (s.size() <= 2) {
    printf("%d\n", n);
    return 0;
  }
  dp[0][0] = 1;
  for (auto p : s) {
    for (int i = 10000; i >= 0; i--) {
      for (int j = 0; j <= n; j++) {
        for (int k = 1; k * p.first <= i && k <= j && k <= p.second; k++) {
          dp[i][j] += dp[i - p.first * k][j - k];
          dp[i][j] = min(dp[i][j], (int)1e9);
        }
      }
    }
  }
  int res = 1;
  for (auto p : s) {
    for (int i = 1; i <= p.second; i++) {
      if (dp[p.first * i][i] == 1) res = max(res, i);
    }
  }
  printf("%d\n", res);
}
