#include <bits/stdc++.h>
using namespace std;
const int N = 110;
const int mod = 1e9 + 7;
int n, A[N], f[N * N][N], pos, ans, cnt[N];
long long C[N][N];
bool book[N * N];
void init() {
  for (int i = 0; i <= N - 1; i++) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j <= i; j++)
      C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
  }
}
int main() {
  init();
  cin >> n;
  int flag = 0;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
    if (!cnt[A[i]]) flag++;
    cnt[A[i]]++;
  }
  if (flag == 2 || flag == 1) return 0 * printf("%d", n);
  f[0][0] = 1;
  book[0] = 1;
  for (int i = 1; i <= n; i++)
    for (int m = 10000; m >= A[i]; m--) {
      if (!book[m - A[i]]) continue;
      for (int t = 1; t <= 100; t++) {
        f[m][t] = (f[m][t] + f[m - A[i]][t - 1]) % mod;
        book[m] = 1;
      }
    }
  for (int i = 1; i <= 100; i++)
    for (int t = 1; t <= cnt[A[i]]; t++)
      if (f[A[i] * t][t] == C[cnt[A[i]]][t]) ans = max(ans, t);
  cout << ans;
  return 0;
}
