#include <bits/stdc++.h>
using namespace std;
int dp[102][10200];
int dp2[102][10200];
int N;
int A[102], cum[102];
const int MD = 1e9 + 9;
int C[101][101];
int cntz[10200];
int nCr(int N, int R) {
  if (N == R || R == 0) {
    return 1;
  }
  if (R < 0 || N < R) {
    return 0;
  }
  if (C[N][R]) {
    return C[N][R];
  }
  return (C[N][R] = (nCr(N - 1, R) + nCr(N - 1, R - 1)) % MD);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> N;
  map<int, int> freq;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    freq[A[i]]++;
    cum[i + 1] = cum[i] + A[i];
  }
  if (freq.size() <= 2) {
    cout << N << '\n';
    return 0;
  }
  dp[0][0] = 1;
  for (int i = 0; i < N; i++) {
    for (int subs = i + 1; subs >= 1; subs--) {
      for (int val = A[i]; val <= cum[i + 1]; val++) {
        dp[subs][val] += dp[subs - 1][val - A[i]];
        if (dp[subs][val] >= MD) {
          dp[subs][val] -= MD;
        }
      }
    }
  }
  int ans = 1;
  for (auto u : freq) {
    for (int i = 2; i <= u.second; i++) {
      int cnt = dp[i][i * u.first];
      int kek = nCr(u.second, i);
      if (cnt == kek) {
        ans = max(ans, i);
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
