#include <bits/stdc++.h>
using namespace std;
long long C[105][105];
long long modset[10] = {1097774749, 1076767633, 100102021, 999997771,
                        1001010013, 1000512343, 987654361, 999991231,
                        999888733,  987777733};
long long mod;
void build() {
  for (int i = 0; i <= 100; i++) {
    C[i][0] = C[i][i] = 1;
  }
  for (int i = 1; i <= 100; i++)
    for (int j = 1; j < i; j++) {
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
    }
}
long long dp[105][10005];
int main() {
  srand(time(NULL));
  mod = modset[rand() % 10];
  build();
  int n;
  scanf("%d", &n);
  int a[105];
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  if (n == 2) {
    printf("2\n");
    return 0;
  }
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = i - 1; j >= 0; j--) {
      for (int k = 10000 - a[i]; k >= 0; k--) {
        dp[j + 1][k + a[i]] += dp[j][k];
        dp[j + 1][k + a[i]] %= mod;
      }
    }
  int cnt[105];
  memset(cnt, 0, sizeof(cnt));
  vector<int> v;
  for (int i = 1; i <= n; i++) {
    cnt[a[i]]++;
    if (cnt[a[i]] == 1) v.push_back(a[i]);
  }
  if (v.size() == 2) {
    if (cnt[v[0]] * v[0] != cnt[v[1]] * v[1]) {
      printf("%d\n", n);
      return 0;
    }
  }
  int ans = 1;
  for (int i = 1; i <= 100; i++) {
    for (int j = cnt[i]; j > 0; j--) {
      if (C[cnt[i]][j] == dp[j][j * i]) {
        ans = max(ans, j);
        break;
      }
    }
  }
  printf("%d\n", ans);
}
