#include <bits/stdc++.h>
using namespace std;
int dp[2][101][10001];
int n;
int a[101];
int h[101];
const int mod = 1e9 + 7;
inline void upd(int &a, int b) {
  a = (a + b) % mod;
  return;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    h[a[i]]++;
  }
  int cur = 0;
  int sig = 0, pre = 0;
  dp[1][0][0] = 1;
  for (int i = 1; i <= 100; i++) {
    memset(dp[cur], 0, sizeof(dp[cur]));
    for (int j = 0; j <= h[i]; j++) {
      for (int k = 0; k <= pre; k++) {
        for (int l = 0; l <= sig; l++) {
          upd(dp[cur][k + j][l + i * j], dp[cur ^ 1][k][l]);
        }
      }
    }
    pre += h[i];
    sig += i * h[i];
    cur ^= 1;
  }
  cur ^= 1;
  int ans = 0;
  int tt = 0;
  for (int i = 1; i <= 100; i++) {
    if (h[i]) tt++;
  }
  for (int i = 1; i <= 100; i++) {
    if (h[i]) {
      int ra = 0;
      for (int k = 1; k <= h[i]; k++) {
        if (dp[cur][k][i * k] == 1) {
          ra = max(ra, k);
          if (tt == 2 && k == h[i]) ra = max(ra, n);
        }
      }
      ans = max(ans, ra);
    }
  }
  cout << ans << endl;
  return 0;
}
