#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& o, const vector<T>& xs) {
  for (auto p : xs) {
    cout << p << " ";
  }
  cout << "\n";
  return o;
}
int DP[2][101][101 * 101];
int Typ[101][101 * 101];
bool Byl[101];
vector<int> V;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int SumaWag = 0;
  int Rozne = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    SumaWag += a;
    V.push_back(a);
    if (Byl[a] == false) {
      Byl[a] = true;
      Rozne++;
    }
  }
  if (Rozne == 2) {
    cout << n << "\n";
    return 0;
  }
  sort(V.begin(), V.end());
  DP[0][0][0] = 1;
  Typ[0][0] = -1;
  DP[0][1][V[0]] = 1;
  Typ[1][V[0]] = V[0];
  for (int i = 1; i < n; i++) {
    for (int p = n; p > 0; p--) {
      for (int s = SumaWag; s >= V[i]; s--) {
        if (DP[(i + 1) % 2][p - 1][s - V[i]] == 0) {
          continue;
        }
        if (DP[(i + 1) % 2][p - 1][s - V[i]] == 1 && Typ[p][s] == 0) {
          if (Typ[p - 1][s - V[i]] == V[i] || Typ[p - 1][s - V[i]] == -1) {
            DP[i % 2][p][s] = 1;
            Typ[p][s] = V[i];
          } else {
            DP[i % 2][p][s] = 2;
          }
        } else if (DP[(i + 1) % 2][p - 1][s - V[i]] == 2 || Typ[p][s] != V[i]) {
          DP[i % 2][p][s] = 2;
          Typ[p][s] = 1;
        }
      }
      for (int s = 100 * 100; s >= 0; s--) {
        DP[i % 2][p][s] = max(DP[(i + 1) % 2][p][s], DP[i % 2][p][s]);
      }
    }
    DP[i % 2][0][0] = 1;
  }
  int wynik = -1;
  for (int p = 0; p <= n; p++) {
    for (int s = 1; s <= SumaWag; s++) {
      if (DP[(n - 1) % 2][p][s] == 1) {
        wynik = max(wynik, p);
      }
    }
  }
  cout << wynik << "\n";
}
