#include <bits/stdc++.h>
using namespace std;
const int MAXN = 105;
int n, lim;
int A[MAXN], C[MAXN * MAXN][MAXN];
map<int, int> M;
void createme() {
  C[0][0] = 1;
  lim = 1;
  for (pair<int, int> t : M) {
    for (int i = (int)(lim - 1); i >= (0); i--)
      for (int j = (0); j < (int)(MAXN); j++)
        if (C[i][j]) {
          for (int k = (0); k < (int)(t.second); k++) {
            int val = t.first * (k + 1);
            C[i + val][j + k + 1] += C[i][j];
            C[i + val][j + k + 1] = min(C[i + val][j + k + 1], 2);
            lim = max(lim, i + val + 1);
          }
        }
  }
}
int main() {
  while (scanf("%d", &n) >= 1) {
    memset(C, 0, sizeof C);
    M.clear();
    for (int i = (0); i < (int)(n); i++) {
      int x;
      scanf("%d", &x);
      M[x]++;
    }
    if (((int)M.size()) < 3) {
      printf("%d\n", n);
      continue;
    }
    createme();
    int ans = 0;
    for (pair<int, int> t : M) {
      int act = 0;
      for (int i = (0); i < (int)(t.second); i++) {
        act += t.first;
        if (C[act][i + 1] == 1) ans = max(ans, i + 1);
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
