#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int MOD = 998244353;
const int MAXN = (int)1e2 + 5;
const int MAXS = (int)1e4 + 5;
ull dp[MAXN][MAXS];
ull C[MAXN][MAXN];
int n;
int a[MAXN];
map<int, int> m;
int main() {
  for (int i = 0; i < MAXN; ++i)
    for (int j = 0; j < MAXN; ++j)
      if (j == 0 || j == i)
        C[i][j] = 1;
      else if (j > i)
        C[i][j] = 0;
      else
        C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    m[a[i]]++;
  }
  dp[0][0] = 1;
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j > 0; --j)
      for (int sum = a[i]; sum < MAXS; ++sum)
        dp[j][sum] += dp[j - 1][sum - a[i]];
  int sol = 1;
  for (auto x : m) {
    int num = x.first;
    int cnt = x.second;
    for (int i = 2; i <= cnt; ++i)
      if (dp[i][num * i] == C[cnt][i]) {
        if (m.size() == 2 && i == cnt) sol = n;
        sol = max(sol, i);
      }
  }
  cout << sol;
  return 0;
}
