#include <bits/stdc++.h>
using namespace std;
int dp[101][10101];
int main() {
  int n;
  cin >> n;
  vector<int> qt(101);
  int distinct = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    qt[x]++;
    if (qt[x] == 1) {
      distinct++;
    }
  }
  int ts = 0, tq = 0;
  dp[0][0] = 1;
  int ans = 0;
  for (int i = 1; i <= 100; i++) {
    if (!qt[i]) {
      continue;
    }
    for (int s = ts; s >= 0; s--) {
      for (int k = 0; k <= tq; k++) {
        if (dp[k][s]) {
          for (int l = 1; l <= qt[i]; l++) {
            dp[k + l][s + i * l] = min(2, dp[k][s] + dp[k + l][s + i * l]);
          }
        }
      }
    }
    ts += i * qt[i];
    tq += qt[i];
  }
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= qt[i]; j++) {
      if (dp[j][j * i] == 1) {
        ans = max(ans, j);
        if (j == qt[i] && distinct == 2) {
          ans = n;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
