#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 7;
int a[maxn], dp[maxn][105];
int main() {
  int n;
  scanf("%d", &n);
  map<int, int> vis;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    vis[a[i]]++;
  }
  vector<pair<int, int> > v;
  for (auto p : vis) v.push_back(p);
  dp[0][0] = 1;
  for (auto p : v) {
    int vol = p.first;
    int k = p.second;
    for (int i = 1e4; i > 0; i--)
      for (int j = 1; j <= n; j++)
        for (int t = 1; t <= k && t <= j && i - vol * t >= 0; t++) {
          dp[i][j] += dp[i - vol * t][j - t];
          dp[i][j] = min(dp[i][j], 2);
        }
  }
  if (v.size() == 2) {
    printf("%d\n", n);
    return 0;
  }
  int ans = 1;
  for (auto p : v) {
    int vol = p.first;
    int k = p.second;
    for (int i = 1; i <= k; i++)
      if (dp[i * vol][i] == 1) ans = max(ans, i);
  }
  printf("%d\n", ans);
  return 0;
}
