#include <bits/stdc++.h>
using namespace std;
const int limit = 105;
const int LIMIT = limit * limit;
void maximize(int &a, int b) { a = max(a, b); }
void write(bitset<LIMIT> b[limit]) {
  for (int k = 0; k < limit; k++) {
    bool some = false;
    for (int i = 0; i < LIMIT; i++) {
      if (b[k][i]) {
        cout << "(" << k << "," << i << ")";
        some = true;
      }
    }
    if (some) cout << endl;
  }
}
int howmany[limit];
bitset<LIMIT> ant[limit];
bitset<LIMIT> more1[limit];
bitset<LIMIT> act;
int sol;
set<int> s;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    howmany[x]++;
    s.insert(x);
  }
  if (int(s.size()) <= 2) {
    cout << n << endl;
    exit(0);
  }
  ant[0][0] = 1;
  for (int val = 1; val < limit; val++) {
    for (int k = limit - 1; k >= 1; k--) {
      for (int ocur = 1; ocur <= min(howmany[val], k); ocur++) {
        int desp = val * ocur;
        act = ant[k - ocur] << desp;
        more1[k] |= act & ant[k];
        ant[k] |= act;
      }
    }
  }
  for (int val = 1; val < limit; val++)
    for (int ocur = 1; ocur <= howmany[val]; ocur++)
      if (not more1[ocur][val * ocur]) maximize(sol, ocur);
  cout << sol << endl;
}
