#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, sol = 0, cs = 0;
  cin >> n;
  vector<int> a(n);
  vector<vector<int>> DP(n + 1, vector<int>(100 * n + 1));
  map<int, int> m;
  DP[0][0] = 1;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    m[a[i]]++;
  }
  if (m.size() <= 2) {
    cout << n << endl;
    return 0;
  }
  for (auto u : m) {
    cs += u.first * u.second;
    for (int k = n; k >= 0; k--)
      for (int j = cs; j >= 0; j--)
        for (int i = 1; i <= min(k, u.second); i++)
          if (j - i * u.first >= 0) {
            DP[k][j] += DP[k - i][j - i * u.first];
            DP[k][j] = min(2, DP[k][j]);
          }
  }
  for (auto u : m)
    for (int i = 1; i <= u.second; i++)
      if (DP[i][u.first * i] == 1) sol = max(sol, i);
  cout << sol << endl;
  return 0;
}
