#include <bits/stdc++.h>
#pragma warning(disable : 4786)
#pragma warning(disable : 4996)
using namespace std;
int n;
int cnt[102], a[102];
vector<pair<int, int> > V;
int sz;
const int p[2] = {102352333, 876209077};
int ncr[2][102][102];
int way[2][102][10002];
int ans;
void solve() {
  for (int k = 0; k < 2; k++) {
    ncr[k][0][0] = 1;
    int limncr = 100;
    for (int i = 1; i <= limncr; i++)
      for (int j = 0; j <= limncr; j++) {
        if (j > i)
          ncr[k][i][j] = 0;
        else if (j == i || j == 0)
          ncr[k][i][j] = 1;
        else {
          ncr[k][i][j] = ncr[k][i - 1][j - 1] + ncr[k][i - 1][j];
          if (ncr[k][i][j] >= p[k]) ncr[k][i][j] -= p[k];
        }
      }
  }
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    cnt[a[i]]++;
  }
  for (int i = 1; i <= 100; i++) {
    if (cnt[i]) {
      V.push_back({i, cnt[i]});
    }
  }
  sz = (int)V.size();
  sort(V.begin(), V.end());
  ans = 0;
  for (int kk = 0; kk < 2; kk++) {
    way[kk][0][0] = 1;
    int mxsum = 0;
    for (int i = 1; i <= n; i++) {
      int val = a[i];
      for (int j = i - 1; j >= 0; j--) {
        for (int k = mxsum; k >= 0; k--) {
          way[kk][j + 1][k + val] += way[kk][j][k];
          if (way[kk][j + 1][k + val] >= p[kk]) {
            way[kk][j + 1][k + val] -= p[kk];
          }
        }
      }
      mxsum += val;
    }
  }
  for (int i = 0; i < (int)V.size(); i++) {
    for (int j = ans + 1; j <= V[i].second; j++) {
      if (way[0][j][j * V[i].first] == ncr[0][V[i].second][j] &&
          way[1][j][j * V[i].first] == ncr[1][V[i].second][j]) {
        ans = j;
      }
    }
  }
  if (sz == 2) ans = n;
  printf("%d\n", ans);
}
int main() {
  double start_time = clock();
  solve();
  double end_time = clock();
  fprintf(stderr, "Time = %lf\n", (end_time - start_time) / CLOCKS_PER_SEC);
  return 0;
}
