#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int a[n];
  int sm = 0;
  int fr[101] = {0};
  for (int i = 0; i < n; i++) cin >> a[i], sm += a[i], fr[a[i]]++;
  int cnt = 0;
  for (int i = 1; i <= 100; i++)
    if (fr[i]) cnt++;
  if (cnt <= 2) {
    cout << n << "\n";
    return 0;
  }
  int dp[sm + 1][n + 1];
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = sm - a[i]; j >= 0; j--) {
      for (int k = 0; k <= i; k++) {
        dp[j + a[i]][k + 1] += dp[j][k];
      }
    }
  }
  int ans = 0;
  int c[n + 1][n + 1];
  for (int i = 0; i <= n; i++) {
    c[i][0] = 1;
    c[i][i] = 1;
    for (int j = 1; j < i; j++) c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
  }
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= fr[i]; j++) {
      if (dp[j * i][j] == c[fr[i]][j]) ans = max(ans, j);
    }
  }
  cout << ans << "\n";
  return 0;
}
