#include <bits/stdc++.h>
using namespace std;
const int MAX = 101;
const int RAN = 10001;
int n, a[MAX];
int sum[MAX], nx[MAX];
int best[2][RAN];
bool dup[2][RAN];
int ans() {
  int res = 1;
  sort(a + 1, a + n + 1);
  for (int i = 0, j = 0; i <= n + 1 && j <= n; i++) {
    if (i <= n && a[i] == a[j]) continue;
    while (j < i) nx[j++] = i;
  }
  fill(best[0], best[0] + RAN, -1);
  fill(dup[0], dup[0] + RAN, 0);
  best[0][0] = 0;
  for (int k = (1); k < (n + 1); ++k) {
    fill(best[k & 1], best[k & 1] + RAN, -1);
    fill(dup[k & 1], dup[k & 1] + RAN, 0);
    for (int j = (0); j < (RAN); ++j) {
      if (best[(k - 1) & 1][j] < 0) continue;
      for (int x = best[(k - 1) & 1][j] + 1; x <= n; x = nx[x]) {
        int& val = best[k & 1][j + a[x]];
        if (val >= 0 || dup[(k - 1) & 1][j]) dup[k & 1][j + a[x]] = 1;
        if (val < 0 || val > x) val = x;
      }
    }
    for (int i = (1); i < (MAX); ++i)
      if (sum[i] >= k && !dup[k & 1][i * k])
        if (res < k) res = k;
  }
  int numtype = 0;
  for (int i = (1); i < (MAX); ++i)
    if (sum[i] > 0) numtype++;
  if (numtype == 2) res = n;
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  a[0] = 0;
  for (int i = (0); i < (n); ++i) {
    cin >> a[i + 1];
    sum[a[i + 1]]++;
  }
  cout << ans() << endl;
  return 0;
}
