#include <bits/stdc++.h>
using namespace std;
const int P = 1e9 + 7, INF = 0x3f3f3f3f;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long qpow(long long a, long long n) {
  long long r = 1 % P;
  for (a %= P; n; a = a * a % P, n >>= 1)
    if (n & 1) r = r * a % P;
  return r;
}
long long inv(long long first) {
  return first <= 1 ? 1 : inv(P % first) * (P - P / first) % P;
}
inline int rd() {
  int first = 0;
  char p = getchar();
  while (p < '0' || p > '9') p = getchar();
  while (p >= '0' && p <= '9') first = first * 10 + p - '0', p = getchar();
  return first;
}
const int N = 105;
int n, a[N], cnt[N];
short dp[N][N][N * N];
int pre[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i), ++cnt[a[i]];
  dp[0][0][0] = 1;
  int mx = 0;
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n; ++i) {
    mx += a[i];
    memcpy(dp[i], dp[i - 1], sizeof dp[i]);
    for (int j = mx; j >= a[i]; --j)
      for (int k = i; k >= 1; --k) dp[i][k][j] += dp[i - 1][k - 1][j - a[i]];
    if (pre[a[i]]) {
      for (int j = mx; j >= a[i]; --j)
        for (int k = i; k >= 1; --k)
          dp[i][k][j] -= dp[pre[a[i]] - 1][k - 1][j - a[i]];
    }
    pre[a[i]] = i;
  }
  int ans = 1;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= mx; ++j)
      if (dp[n][i][j] == 1) {
        int ok = 0;
        if (j % i == 0 && cnt[j / i] >= i) {
          ++ok;
          ans = max(ans, i);
        }
        if (i != n && (mx - j) % (n - i) == 0 &&
            cnt[(mx - j) / (n - i)] >= n - i) {
          ++ok;
          ans = max(ans, n - i);
        }
        if (ok == 2) return printf("%d\n", n), 0;
      }
  printf("%d\n", ans);
}
