#include <bits/stdc++.h>
template <typename T, typename S>
inline bool upmin(T& a, const S& b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T, typename S>
inline bool upmax(T& a, const S& b) {
  return a < b ? a = b, 1 : 0;
}
using namespace std;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
inline bool is_down(char x) { return ('a' <= x && x <= 'z'); }
inline bool is_upper(char x) { return ('A' <= x && x <= 'Z'); }
inline bool is_digit(char x) { return ('0' <= x && x <= '9'); }
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = 10 * x + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline long long readll() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = 10 * x + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }
long long power(long long x, long long y) {
  long long t = 1;
  for (; y; y >>= 1, x = x * x % (1000000009))
    if (y & 1) t = t * x % (1000000009);
  return t;
}
int n, m, a[(100 + 5)], b[(100 + 5)];
long long dp[(100 + 5)][10005], c[(100 + 5)][(100 + 5)];
int main() {
  n = read();
  m = 0;
  for (int i = 1; i <= n; i++) a[i] = read(), m += a[i], b[a[i]]++;
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = m; j >= a[i]; j--)
      for (int k = 1; k <= i; k++) {
        dp[k][j] += dp[k - 1][j - a[i]];
      }
  c[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    c[i][0] = c[i][i] = 1;
    for (int j = 1; j <= i - 1; j++) c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
  }
  int ans = 0;
  for (int i = 1; i <= 100; i++)
    for (int j = 1; j <= b[i]; j++) {
      if (dp[j][j * i] == c[b[i]][j]) ans = max(ans, j);
    }
  for (int i = 1; i <= 100; i++)
    for (int j = 1; j <= 100; j++)
      if (i != j && b[i] * i + b[j] * j == m) {
        if (dp[b[i]][b[i] * i] == 1) ans = max(ans, n);
      }
  cout << ans << endl;
  return 0;
}
