#include <bits/stdc++.h>
using namespace std;
const int N1 = 103;
const long long p = 99999999999999997;
long long C[N1][N1];
void pre() {
  C[0][0] = 1;
  for (int i = 1; i <= 100; i++) {
    for (int j = 0; j <= i; j++) {
      C[i][j] = C[i - 1][j];
      if (j) (C[i][j] += C[i - 1][j - 1]) %= p;
    }
  }
}
int n, m, cnt;
int a[N1], sum[N1];
long long f[N1 * N1][N1];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++)
    if (a[i] != a[i - 1]) cnt++;
  f[0][0] = 1;
  pre();
  for (int i = 1; i <= n; i++) {
    for (int j = m; j >= 0; j--) {
      for (int k = i - 1; k >= 0; k--) {
        (f[j + a[i]][k + 1] += f[j][k]) %= p;
      }
    }
    m += a[i];
  }
  for (int i = 1; i <= n; i++) sum[a[i]]++;
  int ans = 0;
  for (int i = 1; i <= 100; i++) {
    for (int k = 1; k <= sum[i]; k++) {
      if (f[i * k][k] == C[sum[i]][k]) {
        ans = max(ans, k);
        if (cnt == 2 && k == sum[i]) ans = n;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
