#include <bits/stdc++.h>
using namespace std;
const int maxn = 100007;
const int mod = 1e9 + 7;
const int inf = (1LL << 29);
int a[maxn], num[107];
int dp[10007][107], vis[107];
int p[maxn], inv[maxn];
int pown(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = (1LL * ans * a) % mod;
    a = (1LL * a * a) % mod;
    b >>= 1;
  }
  return ans;
}
int c(int x, int y) { return ((1LL * p[x] * inv[y]) % mod * inv[x - y]) % mod; }
int main() {
  int n;
  cin >> n;
  int sum = 0;
  int col = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    num[a[i]]++;
    if (!vis[a[i]]) vis[a[i]] = 1, col++;
  }
  p[0] = inv[0] = 1;
  for (int i = 1; i <= n; i++) p[i] = (1LL * p[i - 1] * i) % mod;
  for (int i = 1; i <= n; i++) inv[i] = pown(p[i], mod - 2);
  dp[0][0] = 1;
  for (register int i = 1; i <= n; i++) {
    sum += a[i];
    for (register int k = sum; k >= a[i]; k--)
      for (register int z = n; z; z--) (dp[k][z] += dp[k - a[i]][z - 1]) %= mod;
  }
  int mx = 0;
  for (register int i = 1; i <= 100; i++) {
    for (int k = 1; k <= num[i]; k++) {
      if (dp[k * i][k] == c(num[i], k)) mx = max(mx, k);
    }
  }
  cout << (col <= 2 ? n : mx);
  return 0;
}
