#include <bits/stdc++.h>
using namespace std;
int n, N;
int a[106], mx;
long long dp[2][10006][106];
int ans;
int maxi(int &a, int b) { return a = max(a, b); }
int f[106];
int ncr[106][106];
int mod = 1e9 + 7;
int add(int a, int b) { return (a % mod + b % mod) % mod; }
void nCr() {
  for (int i = 0; i < 106; i++) {
    for (int j = 0; j <= i; j++) {
      if (i == j || j == 0)
        ncr[i][j] = 1;
      else
        ncr[i][j] = add(ncr[i - 1][j - 1], ncr[i - 1][j]);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    mx += a[i];
    N += (f[a[i]] == 0);
    f[a[i]]++;
  }
  if (N <= 2) {
    printf("%d", n);
    return 0;
  }
  sort(a + 1, a + n + 1);
  nCr();
  dp[0][0][0] = dp[1][0][0] = 1;
  int p = 1;
  for (int i = 1; i <= n; i++) {
    p = !p;
    for (int m = a[1]; m <= mx; m++) {
      for (int k = 1; k <= n; k++) {
        dp[p][m][k] = dp[!p][m][k];
        if (m - a[i] >= 0)
          dp[p][m][k] = add(dp[p][m][k], dp[!p][m - a[i]][k - 1]);
        if (i == n) {
          if (m % k == 0 && f[m / k] >= k && dp[p][m][k] == ncr[f[m / k]][k])
            maxi(ans, k);
        }
      }
    }
  }
  printf("%d", ans);
  return 0;
}
