#include <bits/stdc++.h>
using namespace std;
const long long MD1 = (long long)1e9 + 7;
const long long MD2 = (long long)1e9 + 9;
long long n, MX;
long long a[100 + 1], cnt[100 + 1];
set<long long> types;
long long cnt_c[2][100 * 100 + 5][100 + 5];
long long nCr_memo[100 + 5][100 + 5][2];
long long nCr(long long a, long long b, long long k) {
  if (nCr_memo[a][b][k] != -1) return nCr_memo[a][b][k];
  long long res;
  if (b > a)
    res = 0;
  else if (a == b || b == 0)
    res = 1;
  else
    res = (nCr(a - 1, b, k) + nCr(a - 1, b - 1, k)) % (k ? MD1 : MD2);
  return nCr_memo[a][b][k] = res;
}
long long pre_sum[100 + 1];
long long cnt_dp[2][2][100 * 100 + 5][100 + 5];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  memset(nCr_memo, -1, sizeof nCr_memo);
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
    MX += a[i];
    pre_sum[i] = a[i];
    if (i > 0) pre_sum[i] += pre_sum[i - 1];
    types.insert(a[i]);
  }
  if (types.size() < 3) {
    cout << n << endl;
    return 0;
  }
  for (long long k = 0; k < n + 1; k++) {
    for (long long i = 1; i < 100 + 1; i++) {
      signed w = k * i;
      cnt_c[0][w][k] = nCr(cnt[i], k, 0);
      cnt_c[1][w][k] = nCr(cnt[i], k, 1);
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long w = 0; w < MX + 1; w++) {
      for (long long k = 0; k < i + 2; k++) {
        long long res1 = 0, res2 = 0;
        if (k == 0)
          res1 = res2 = (w == 0);
        else if (i == 0)
          res1 = res2 = (a[i] == w);
        else {
          res1 = cnt_dp[0][0][w][k];
          res2 = cnt_dp[1][0][w][k];
          if (w < a[i]) continue;
          res1 = (res1 + cnt_dp[0][0][w - a[i]][k - 1]) % MD1;
          res2 = (res2 + cnt_dp[1][0][w - a[i]][k - 1]) % MD2;
        }
        cnt_dp[0][1][w][k] = res1;
        cnt_dp[1][1][w][k] = res2;
      }
    }
    for (long long w = 0; w < MX + 1; w++) {
      for (long long k = 0; k < i + 2; k++) {
        cnt_dp[0][0][w][k] = cnt_dp[0][1][w][k];
        cnt_dp[1][0][w][k] = cnt_dp[1][1][w][k];
      }
    }
  }
  for (long long k = n; k > 0; k--) {
    for (long long w = 0; w < MX + 1; w++) {
      bool a = (cnt_c[0][w][k] == cnt_dp[0][0][w][k]);
      bool b = (cnt_c[1][w][k] == cnt_dp[1][0][w][k]);
      if ((a || b) && (cnt_c[0][w][k] || cnt_c[1][w][k])) {
        cout << k << endl;
        return 0;
      }
    }
  }
  return 0;
}
