#include <bits/stdc++.h>
using namespace std;
const int N = 110, M = N * N, MOD = 1000 * 1000 * 1000 + 7;
int n, a, s, ans, cnt[N], c[N][N], dp[2][N][M];
int sum(int a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
  return a;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  fill(c[0], c[0] + N, 1);
  for (int i = 1; i < N; i++)
    for (int j = 1; j < N; j++) c[i][j] = sum(c[i - 1][j - 1], c[i][j - 1]);
  dp[0][0][0] = 1;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a;
    s += a;
    cnt[a]++;
    auto last = dp[!(i & 1)], now = dp[i & 1];
    for (int j = 0; j < N; j++)
      for (int k = 0; k < M; k++) now[j][k] = 0;
    for (int j = 0; j <= i; j++)
      for (int k = 0; k <= s; k++)
        now[j][k] = sum(last[j][k], (a <= k && j ? last[j - 1][k - a] : 0));
  }
  int type_cnt = 0;
  for (int i = 1; i < N; i++) type_cnt += (cnt[i] > 0);
  for (int want = 1; want <= n; want++)
    for (int sum = want; sum <= s; sum += want)
      if (dp[n & 1][want][sum] &&
          dp[n & 1][want][sum] == c[want][cnt[sum / want]]) {
        ans = want;
        if (type_cnt == 2 && want == cnt[sum / want]) ans = n;
      }
  cout << ans;
  return 0;
}
