#include <bits/stdc++.h>
using namespace std;
const int maxm = 105;
int dp[maxm][maxm * maxm];
int len;
int num[maxm];
int sum[maxm];
int MOD[] = {1000000009, 1000000007, 998244353, 19260817};
struct {
  int mod;
  int add(int a, int b) { return (a + b) % mod; }
  int mul(long long a, long long b) { return a * b % mod; }
  int qpow(int a, int b) {
    int ret = 1;
    while (b) {
      if (b & 1) ret = mul(ret, a);
      a = mul(a, a);
      b >>= 1;
    }
    return ret;
  }
  int fac[maxm];
  int invf[maxm];
  void init() {
    mod = MOD[rand() % 4];
    fac[0] = 1;
    for (int i = 1; i < maxm; i++) fac[i] = mul(fac[i - 1], i);
    invf[maxm - 1] = qpow(fac[maxm - 1], mod - 2);
    for (int i = maxm - 2; i >= 0; i--) invf[i] = mul(invf[i + 1], i + 1);
  }
  int C(int a, int b) {
    if (b < 0 || b > a) return 0;
    if (b == 0 || b == a) return 1;
    return mul(fac[a], mul(invf[b], invf[a - b]));
  }
} number_theory;
int cnt[maxm];
bool check(int a, int b) {
  if (b % a != 0) return false;
  int now = b / a;
  int cnt = ::cnt[now];
  if (number_theory.C(cnt, a) == dp[a][b]) return true;
  return false;
}
int main() {
  srand(time(0));
  number_theory.init();
  scanf("%d", &len);
  int has = 0;
  for (int i = 1; i <= len; i++) {
    scanf("%d", num + i);
    sum[i] = sum[i - 1] + num[i];
    if (cnt[num[i]] == 0) has++;
    cnt[num[i]]++;
  }
  if (has == 1 || has == 2) {
    printf("%d\n", len);
    return 0;
  }
  sort(num, num + len);
  dp[0][0] = 1;
  for (int i = 1; i <= len; i++) {
    for (int j = sum[i]; j >= num[i]; j--) {
      for (int k = 1; k <= i; k++) {
        dp[k][j] = number_theory.add(dp[k][j], dp[k - 1][j - num[i]]);
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= len; i++) {
    for (int j = 1; j <= sum[len]; j++) {
      if (dp[i][j]) {
        if (check(i, j)) ans = max(ans, i);
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
