#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int maxn = 120;
const int inf = 0x3f3f3f3f;
long long dp[maxn][maxn * maxn];
long long t[maxn][maxn * maxn];
int cnt[maxn], a[maxn];
int main() {
  int n, m = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i), m += a[i], cnt[a[i]]++;
  dp[0][0] = 1;
  int sum = 0;
  int f = 0;
  for (int i = 1; i <= 100; ++i) {
    if (!cnt[i]) continue;
    ++f;
    sum += cnt[i];
    memmove(t, dp, sizeof dp);
    memset(dp, 0, sizeof dp);
    for (int j = 0; j <= sum; ++j) {
      for (int k = 0; k <= m; ++k) {
        dp[j][k] = t[j][k];
        if (j)
          for (int s = 1; s <= cnt[i] && s <= j && s * i <= k; ++s) {
            dp[j][k] = (dp[j][k] + t[j - s][k - s * i]) % MOD;
          }
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (j % i == 0 && dp[i][j] == 1 && cnt[j / i] >= i) {
        ans = i;
      }
    }
  }
  if (f == 2) ans = n;
  cout << ans << endl;
  return 0;
}
