#include <bits/stdc++.h>
using namespace std;
constexpr int MOD = 998244353;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> cnt(1 + 100, 0);
  int sum = 0;
  int cnt_diff = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    ++cnt[a[i]];
    if (cnt[a[i]] == 1) {
      ++cnt_diff;
    }
    sum += a[i];
  }
  if (cnt_diff <= 2) {
    cout << n;
    return 0;
  }
  vector<vector<int>> dp(1 + sum, vector<int>(1 + n, 0));
  dp[0][0] = 1;
  for (int i = 0; i < n; ++i) {
    for (int j = n; j > 0; --j) {
      for (int ss = sum; ss >= a[i]; --ss) {
        dp[ss][j] = (dp[ss][j] + dp[ss - a[i]][j - 1]) % MOD;
      }
    }
  }
  vector<vector<int>> C(1 + n, vector<int>(1 + n, 0));
  C[0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    C[i][i] = 1;
    C[i][0] = 1;
    for (int j = 1; j < i; ++j) {
      C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
    }
  }
  int res = 0;
  for (int i = 1; i <= 100; ++i) {
    if (cnt[i] == 0) {
      continue;
    }
    for (int j = 1; j <= cnt[i]; ++j) {
      if (dp[j * i][j] == C[cnt[i]][j]) {
        res = max(res, j);
      }
    }
  }
  cout << res << "\n";
}
