#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int MAXN = 105;
int n, a[MAXN];
int dp[MAXN][MAXN * MAXN];
void solve() {
  sort(a, a + n);
  int ans = 0;
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  for (int i = 0; i < n;) {
    int j = i;
    int num = 0;
    while (j < n && a[j] == a[i]) {
      j++;
      num++;
    }
    for (int k = n; k >= 0; k--) {
      for (int sum = 100 * n; sum >= 0; sum--) {
        if (dp[k][sum]) {
          for (int cnt = 1; cnt <= num; cnt++) {
            int nk = k + cnt;
            int ns = sum + cnt * a[i];
            if (nk <= n && ns <= 100 * n) {
              dp[nk][ns] += dp[k][sum];
              if (dp[nk][ns] > 2) {
                dp[nk][ns] = 2;
              }
            }
          }
        }
      }
    }
    i = j;
  }
  int diff = 0;
  for (int i = 0; i < n;) {
    diff++;
    int j = i;
    while (j < n && a[j] == a[i]) {
      int cnt = j - i + 1;
      int sum = cnt * a[i];
      if (dp[cnt][sum] == 1) {
        ans = max(ans, cnt);
      }
      j++;
    }
    i = j;
  }
  if (diff == 2) {
    ans = n;
  }
  cout << ans << endl;
}
int main() {
  while (cin >> n) {
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    solve();
  }
}
