#include <bits/stdc++.h>
using namespace std;
constexpr static int MAXN = 110;
constexpr static int MAXV = 10008;
int n;
int a[MAXN];
int solve() {
  map<int, int> cnt;
  for (int i = 0; i < n; i++) cnt[a[i]]++;
  if (cnt.size() <= 2) return n;
  int best = 1;
  for (auto kv : cnt) {
    if (kv.second <= best) continue;
    vector<bitset<MAXV>> b(kv.second + 1);
    b[0][0] = 1;
    for (int i = 0; i < n; i++)
      if (a[i] != kv.first)
        for (int j = kv.second; j > 0; j--) b[j] |= (b[j - 1] << a[i]);
    for (int j = 1; j <= kv.second; j++) {
      if (b[j][j * kv.first]) break;
      best = max(best, j);
    }
  }
  return best;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  printf("%d\n", solve());
}
