#include <bits/stdc++.h>
using namespace std;
const int mxi = 106;
const long long mod = 1e9 + 7;
const long long inf = 1e18;
const int llg = 18;
int n, sum, a[mxi], dp1[mxi][mxi * mxi], dp2[mxi][mxi * mxi], c[mxi];
set<int> s;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i < n + 1; i++) {
    cin >> a[i];
    c[a[i]]++;
    sum += a[i];
    s.insert(a[i]);
  }
  if (s.size() <= 2) {
    cout << n;
    return 0;
  }
  dp1[0][0] = 1;
  for (int i = 1; i < 101; i++) {
    memset(dp2, 0, sizeof dp2);
    for (int k = 0; k < n + 1; k++) {
      for (int w = 0; w < sum + 1; w++) {
        for (int j = 0; j < c[i] + 1; j++) {
          if (j * i <= w && j <= k) dp2[k][w] += dp1[k - j][w - j * i];
        }
        dp2[k][w] = min(2, dp2[k][w]);
      }
    }
    for (int j = 0; j < n + 1; j++) {
      for (int w = 0; w < sum + 1; w++) {
        dp1[j][w] = dp2[j][w];
      }
    }
  }
  int ans = 0;
  for (int k = 1; k < n + 1; k++) {
    for (int w = 0; w < sum + 1; w++) {
      if (dp1[k][w] == 1) {
        for (int i = 1; i < 101; i++) {
          if (w % i == 0 && w == k * i && w <= c[i] * i) ans = max(ans, k);
        }
      }
    }
  }
  cout << ans;
}
