#include <bits/stdc++.h>
using namespace std;
long long dp[101][10010];
int MOD = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  vector<int> cnt(110, 0);
  int dif = 0;
  for (int i : a) {
    if (i && !cnt[i]) {
      dif++;
    }
    cnt[i]++;
  }
  if (dif <= 2) {
    cout << n;
    return 0;
  }
  dp[0][0] = 1;
  for (int i = 1; i <= 100; i++) {
    for (int k = n; k >= 1; k--) {
      for (int w = 10000; w >= 1; w--) {
        for (int f = 1; f <= min(k, cnt[i]) && f * i <= w; f++) {
          dp[k][w] += dp[k - f][w - i * f];
        }
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= cnt[i]; j++) {
      if (dp[j][j * i] == 1) {
        ans = max(ans, j);
      }
    }
  }
  cout << ans;
  return 0;
}
