#include <bits/stdc++.h>
using namespace std;
const int mo = 1e9 + 7;
void add(long long &x, long long y) {
  x += y;
  if (x >= mo) x -= mo;
}
struct matrix {
  long long c[25][25], n, m;
  matrix() {
    memset(c, 0, sizeof(c));
    n = m = 0;
  }
  matrix operator*(const matrix &rhs) const {
    matrix res;
    res.n = n;
    res.m = rhs.m;
    for (int i = 1; i <= n; i++)
      for (int k = 1; k <= m; k++)
        for (int j = 1; j <= rhs.m; j++)
          add(res.c[i][j], c[i][k] * rhs.c[k][j] % mo);
    return res;
  }
  void print() {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) printf("%lld ", c[i][j]);
      puts("");
    }
  }
} A, B;
matrix qkpow(matrix a, long long t) {
  matrix res;
  res.n = res.m = a.n;
  for (int i = 1; i <= res.n; i++) res.c[i][i] = 1;
  while (t) {
    if (t & 1LL) res = res * a;
    a = a * a;
    t >>= 1;
  }
  return res;
}
int n, t, a[105], cnt[105], sum, maxx;
int C[105][105], ans;
map<pair<int, int>, int> dp, pre;
signed main() {
  scanf("%d", &n);
  ans = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    cnt[a[i]]++;
    sum += a[i], maxx = max(maxx, a[i]);
  }
  for (int i = 0; i <= 100; i++)
    if (cnt[i]) t++;
  for (int i = 0; i <= n; i++) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j < i; j++) C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mo;
  }
  dp[make_pair(0, 0)] = pre[make_pair(0, 0)] = 1;
  for (int i = 1; i <= n; i++) {
    for (__typeof(pre.begin()) it = pre.begin(); it != pre.end(); it++) {
      pair<int, int> cur =
          make_pair(it->first.first + a[i], it->first.second + 1);
      (dp[cur] += it->second) %= mo;
    }
    pre = dp;
  }
  if (t == 1 || t == 2) {
    printf("%d", n);
    return 0;
  }
  for (int i = 1; i <= maxx; i++)
    for (int j = 2; j <= cnt[i]; j++)
      if (dp[make_pair(i * j, j)] == C[cnt[i]][j]) ans = max(ans, j);
  printf("%d\n", ans);
  return 0;
}
