#include <bits/stdc++.h>
using namespace std;
FILE* in = stdin;
FILE* out = stdout;
const int MAX = 102;
int n;
int cnt[MAX];
char dyn[MAX][MAX][MAX * MAX];
char recurse(int weight, int use, int rem) {
  if (dyn[weight][use][rem] != -1) return dyn[weight][use][rem];
  if (use == 0 && rem == 0) {
    return dyn[weight][use][rem] = 1;
  }
  if (use == 0 || rem == 0) {
    return dyn[weight][use][rem] = 0;
  }
  if (weight > 100) {
    return dyn[weight][use][rem] = 0;
  }
  char ans = 0;
  for (int t = 0; t <= cnt[weight]; t++) {
    if (use < t || rem < t * weight) break;
    char cur = recurse(weight + 1, use - t, rem - t * weight);
    ans = (char)min(2, ans + cur);
  }
  return dyn[weight][use][rem] = ans;
}
int main(void) {
  int a[MAX];
  fscanf(in, "%d", &n);
  for (int i = 0; i < n; i++) fscanf(in, "%d", &a[i]);
  for (int i = 0; i < n; i++) cnt[a[i]]++;
  int types = 0;
  for (int w = 1; w <= 100; w++) types += !!cnt[w];
  if (types == 2) {
    fprintf(out, "%d\n", n);
    return 0;
  }
  memset(dyn, -1, sizeof(dyn));
  int ans = 0;
  for (int weight = 1; weight <= 100; weight++) {
    for (int use = ans + 1; use <= cnt[weight]; use++) {
      if (recurse(1, use, use * weight) == 1) ans = use;
    }
  }
  fprintf(out, "%d\n", ans);
  return 0;
}
