#include <bits/stdc++.h>
using namespace std;
const int nn = 1e2 + 1;
const int N = 1e4 + 1;
int n, y, z;
int dp[nn][N], f[nn], ch[nn][nn];
vector<int> a;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0, x; i < n; ++i) {
    cin >> x;
    a.push_back(x);
  }
  for (int i = 0; i < nn; ++i) fill(dp[i], dp[i] + N, 0);
  dp[0][0] = 1;
  for (int i = 0; i < n; ++i)
    for (int j = n - 1; j >= 0; --j)
      for (int k = N - 1 - a[i]; k >= 0; --k) dp[j + 1][k + a[i]] += dp[j][k];
  fill(f, f + nn, 0);
  for (auto x : a) ++f[x];
  for (int i = 0; i < nn; ++i) fill(ch[i], ch[i] + nn, 0);
  for (int i = 0; i < nn; ++i) ch[i][0] = ch[i][i] = 1;
  for (int i = 1; i < nn; ++i)
    for (int j = 1; j < i; ++j) ch[i][j] = ch[i - 1][j] + ch[i - 1][j - 1];
  y = -1;
  z = 0;
  for (int i = N - 1; i > 0; --i)
    for (int j = 1; j < nn; ++j)
      if (dp[j][i] && i % j == 0) {
        int k = i / j;
        if (f[k] >= j && ch[f[k]][j] == dp[j][i])
          if (j > z) {
            y = k;
            z = j;
          }
      }
  int cnt = 0;
  for (int i = 0; i < nn; ++i)
    if (f[i] && i != y) ++cnt;
  if (cnt == 1) z = n;
  cout << z << "\n";
  return 0;
}
