#include <bits/stdc++.h>
using namespace std;
int N;
int A[105];
int dp[2][105][10501];
int mo[2] = {1000000007, 1000000021};
int cnt[105];
const int N_ = 1020;
int C_[2][N_][N_];
set<int> S;
void solve() {
  int i, j, k, l, r, x, y;
  string s;
  cin >> N;
  int sum = 0;
  for (i = 0; i < (N); i++) {
    cin >> A[i];
    cnt[A[i]]++;
    sum += A[i];
    S.insert(A[i]);
  }
  if (S.size() <= 2) {
    cout << N << endl;
    return;
  }
  for (x = 0; x < (2); x++) {
    for (i = 0; i < (N_); i++) C_[x][i][0] = C_[x][i][i] = 1;
    for (i = 1; i < N_; i++)
      for (j = 1; j < i; j++)
        C_[x][i][j] = (C_[x][i - 1][j - 1] + C_[x][i - 1][j]) % mo[x];
  }
  for (i = 0; i < (2); i++) {
    dp[i][0][0] = 1;
    for (j = 0; j < (N); j++) {
      for (x = j; x >= 0; x--) {
        for (y = 0; y < (x * 100 + 1); y++)
          if (dp[i][x][y]) {
            dp[i][x + 1][y + A[j]] += dp[i][x][y];
            if (dp[i][x + 1][y + A[j]] >= mo[i])
              dp[i][x + 1][y + A[j]] -= mo[i];
          }
      }
    }
  }
  int ma = 0;
  for (i = 1; i <= 100; i++)
    for (j = 1; j <= cnt[i]; j++)
      if (dp[0][j][i * j] == C_[0][cnt[i]][j] &&
          dp[1][j][i * j] == C_[1][cnt[i]][j])
        ma = max(ma, j);
  cout << ma << endl;
}
int main(int argc, char** argv) {
  string s;
  int i;
  if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);
  for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s += '\n';
  for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);
  cout.tie(0);
  solve();
  return 0;
}
