#include <bits/stdc++.h>
using namespace std;
const int N = 102;
const int Mod = 1e9 + 7;
int f[N][N * N];
int a[N], sum[N], C[N][N];
void Mini(int &a, int b) {
  if (b < a) a = b;
}
void Maxi(int &a, int b) {
  if (b > a) a = b;
}
void add(int &a, int b) { a = (a + b) % Mod; }
map<int, int> M;
void init() {
  C[0][0] = 1;
  for (int i = 1; i < N; i++) {
    C[i][0] = 1;
    for (int j = 1; j < N; j++) {
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % Mod;
    }
  }
}
int main() {
  init();
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", a + i), M[a[i]]++;
  sort(a, a + n);
  for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i - 1];
  f[0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = i; j >= 0; j--)
      for (int s = 0; s <= sum[i]; s++) {
        add(f[j + 1][s + a[i]], f[j][s]);
      }
  }
  int ans = 0;
  if (M.size() <= 2) ans = n;
  for (auto i : M) {
    int x = i.first, c = i.second;
    for (int j = 1; j <= c; j++) {
      if (f[j][x * j] == C[c][j]) Maxi(ans, j);
    }
  }
  printf("%d\n", ans);
}
