#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> L(101, 0);
  int siz = n * 100 + 1;
  vector<vector<int>> DP(siz, vector<int>(n + 1, 0));
  DP[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    L[a]++;
    for (int j = siz - 1; j >= a; j--)
      for (int k = i; k > 0; k--)
        DP[j][k] = (DP[j][k] + DP[j - a][k - 1]) % mod;
  }
  int diff = 0;
  for (int i = 1; i <= 100; i++)
    if (L[i]) diff++;
  if (diff < 3) {
    cout << n << endl;
    return 0;
  }
  vector<vector<int>> nCr(101, vector<int>(101, 0));
  nCr[0][0] = 1;
  for (int i = 1; i < 101; i++) {
    nCr[i][0] = 1;
    for (int j = 1; j <= i; j++)
      nCr[i][j] = (nCr[i - 1][j] + nCr[i - 1][j - 1]) % mod;
  }
  int ans = 1;
  for (int i = 1; i <= 100; i++) {
    for (int j = ans; j <= L[i]; j++) {
      if (DP[i * j][j] == nCr[L[i]][j]) ans = j;
    }
  }
  cout << ans << endl;
  return 0;
}
