#include <bits/stdc++.h>
using namespace std;
const int MOD = (1e9) + 7;
int n;
int a[100 + 1];
int dp[100 + 1][100 * 100 + 1];
int ap[100 + 1];
int comb[100 + 1][100 + 1];
int main() {
  cin >> n;
  int cate = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (ap[a[i]] == 0) cate++;
    ap[a[i]]++;
  }
  if (cate <= 2) {
    cout << n << "\n";
    return 0;
  }
  dp[0][0] = 1;
  for (int h = 1; h <= n; h++) {
    for (int j = 100 * 100 - a[h]; j >= 0; j--) {
      for (int i = 1; i <= n; i++) {
        if (dp[i - 1][j] != 0) {
          dp[i][j + a[h]] += dp[i - 1][j];
          if (dp[i][j + a[h]] >= MOD) dp[i][j + a[h]] -= MOD;
        }
      }
    }
  }
  comb[1][0] = comb[1][1] = 1;
  for (int i = 2; i <= n; i++) {
    comb[i][0] = 1;
    comb[i][1] = i;
    for (int j = 2; j <= i; j++) {
      comb[i][j] = comb[i - 1][j] + comb[i - 1][j - 1];
      if (comb[i][j] >= MOD) comb[i][j] -= MOD;
    }
  }
  int rez = 0;
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= ap[i]; j++) {
      if (dp[j][j * i] == comb[ap[i]][j]) rez = max(rez, j);
    }
  }
  cout << rez << "\n";
  return 0;
}
