#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(char ch) { return string("'") + ch + string("'"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <class InputIterator>
string to_string(InputIterator first, InputIterator last) {
  bool start = true;
  string res = "{";
  while (first != last) {
    if (!start) {
      res += ", ";
    }
    start = false;
    res += to_string(*first);
    ++first;
  }
  res += "}";
  return res;
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
template <typename A, typename B>
istream& operator>>(istream& input, pair<A, B>& x) {
  input >> x.first >> x.second;
  return input;
}
template <typename A>
istream& operator>>(istream& input, vector<A>& x) {
  for (auto& i : x) input >> i;
  return input;
}
unsigned long long binom[105][105][2];
unsigned long long dp[2][105][10005][2];
int cur = 0;
int n;
int sum;
void add(int num) {
  int prev = cur;
  cur ^= 1;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= sum; j++) {
      dp[cur][i][j][0] =
          dp[prev][i][j][0] +
          (i - 1 >= 0 and j - num >= 0 ? dp[prev][i - 1][j - num][0] : 0);
      dp[cur][i][j][1] =
          (dp[prev][i][j][1] +
           (i - 1 >= 0 and j - num >= 0 ? dp[prev][i - 1][j - num][1] : 0)) %
          1000000016000000063LL;
    }
  }
}
void solve() {
  cin >> n;
  vector<int> x(n);
  cin >> x;
  dp[0][0][0][0] = dp[0][0][0][1] = 1;
  sum = accumulate((x).begin(), (x).end(), 0);
  for (auto i : x) {
    add(i);
  }
  sort((x).begin(), (x).end());
  int i = 0;
  int ans = 0;
  while (i < n) {
    int j = i;
    int cursum = 0;
    while (j < n and x[i] == x[j]) {
      j++;
    }
    int k = i;
    while (k < n and x[i] == x[k]) {
      cursum += x[i];
      if (dp[cur][k - i + 1][cursum][0] == binom[j - i][k - i + 1][0] and
          dp[cur][k - i + 1][cursum][1] == binom[j - i][k - i + 1][1]) {
        int res = k - i + 1;
        set<int> s;
        for (int l = 0; l < n; l++) {
          if (l < i or l > k) s.insert(x[l]);
        }
        if ((int)s.size() == 1) res = n;
        ans = max(ans, res);
      }
      k++;
    }
    i = j;
  }
  cout << ans << '\n';
}
int main() {
  binom[0][0][0] = binom[0][0][1] = 1;
  for (int i = 1; i < 105; i++) {
    binom[i][0][0] = binom[i][0][1] = 1;
    binom[i][i][0] = binom[i][i][1] = 1;
    for (int j = 1; j < i; j++) {
      binom[i][j][0] = binom[i - 1][j][0] + binom[i - 1][j - 1][0];
      binom[i][j][1] =
          (binom[i - 1][j][1] + binom[i - 1][j - 1][1]) % 1000000016000000063LL;
    }
  }
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
