#include <bits/stdc++.h>
const long long mod = 1e9 + 7;
using namespace std;
const long long N = 102;
const long long M = 1e4 + 2;
long long dp[N][M], c[N][N], cnt[N];
signed main() {
  long long n, i, j, k, l, ans = 0, type = 0;
  cin >> n;
  dp[0][0] = 1;
  c[0][0] = 1;
  for (i = 1; i <= n; i++) {
    cin >> j;
    if (!cnt[j]) {
      type++;
    }
    cnt[j]++;
    for (l = i; l >= 1; l--) {
      for (k = 10000; k >= j; k--) {
        dp[l][k] += dp[l - 1][k - j];
        if (dp[l][k] > mod) {
          dp[l][k] -= mod;
        }
      }
    }
  }
  if (type <= 2) {
    cout << n;
    return 0;
  }
  for (i = 1; i <= 100; i++) {
    for (j = 0; j <= i; j++) {
      c[j][i] = c[j][i - 1];
      if (j) {
        c[j][i] += c[j - 1][i - 1];
      }
      c[j][i] %= mod;
    }
  }
  for (i = 1; i <= 100; i++) {
    for (j = 1; j <= cnt[i]; j++) {
      if (c[j][cnt[i]] == dp[j][i * j]) {
        ans = max(ans, j);
      }
    }
  }
  cout << ans;
}
