#include <bits/stdc++.h>
using namespace std;
template <class T>
bool umin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool umax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
const int N = 101;
int dp[N][N * N], f[N][N * N], arr[N], C[N][N], cnt[N];
int main() {
  int n, sum = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d", arr + i), cnt[arr[i]]++, sum += arr[i];
  vector<int> v;
  for (int i = 1; i <= 100; i++)
    if (cnt[i]) v.push_back(i);
  if (v.size() == 2) {
    printf("%d\n", n);
    return 0;
  }
  f[0][0] = 1;
  for (int x = 1; x <= n; x++) {
    for (int z = 0; z <= n; z++)
      for (int y = 0; y <= sum; y++) {
        dp[z][y] = f[z][y];
        if (z and y >= arr[x]) dp[z][y] += f[z - 1][y - arr[x]];
        if (dp[z][y] >= 1000000007) dp[z][y] -= 1000000007;
      }
    for (int z = 0; z <= n; z++)
      for (int y = 0; y <= sum; y++) f[z][y] = dp[z][y], dp[z][y] = 0;
  }
  for (int j = 0; j < N; j++) C[j][0] = 1;
  for (int i = 1; i < N; i++)
    for (int j = 1; j <= i; j++) {
      C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]);
      if (C[i][j] >= 1000000007) C[i][j] -= 1000000007;
    }
  memset(dp, -1, sizeof dp);
  int ans = 0;
  for (int i = 1; i <= 100; i++)
    for (int j = cnt[i]; j > ans and j >= 1; j--)
      if (f[j][j * i] == C[cnt[i]][j]) umax(ans, j);
  printf("%d\n", ans);
  return 0;
}
