#include <bits/stdc++.h>
using namespace std;
int cnt[110];
int main() {
  int n;
  cin >> n;
  set<int> s;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    cnt[x]++;
    s.insert(x);
  }
  if (s.size() <= 2) {
    printf("%d\n", n);
    return 0;
  }
  bitset<10010> dp[110];
  dp[0][0] = 1;
  int mx = 1;
  for (int take = 2; take <= n; take++) {
    for (int i = 1; i <= 100; i++)
      if (cnt[i] >= take - 1) {
        for (int k = n; k >= 1; k--) dp[k] = dp[k] | (dp[k - 1] << i);
      }
    for (int i = 1; i <= 100; i++)
      if (cnt[i] >= take && !dp[take][take * i]) mx = take;
  }
  cout << mx << endl;
  return 0;
}
