#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, cnt, ans = 0, sum = 0;
  map<int, int> f;
  cin >> n;
  vector<int> a(n + 1);
  vector<vector<int>> dp(100 * n + 1, vector<int>(n + 1, 0));
  vector<vector<int>> c(n + 1, vector<int>(n + 1, 0));
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
    f[a[i]]++;
  }
  cnt = f.size();
  dp[0][0] = 1;
  c[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    c[i][0] = 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 <= n; i++) {
    for (int j = sum - a[i]; j >= 0; j--)
      for (int k = 0; k < i; k++) dp[j + a[i]][k + 1] += dp[j][k];
  }
  for (int i = 1; i <= 100; i++)
    for (int j = 1; j <= f[i]; j++)
      if (dp[i * j][j] == c[f[i]][j]) {
        ans = max(ans, j);
        if (j == f[i] && cnt == 2) ans = max(ans, n);
      }
  cout << ans;
  return 0;
}
