#include <bits/stdc++.h>
using namespace std;
const int N = 1e2 + 2;
const int N2 = 1e4 + 2;
char dp[N][N][N2];
char maxEl[N][N][N2];
int m, n, ans, sum, cnt[N], bufcnt[N];
vector<int> a;
void read() {
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    cnt[a[i]]++;
    sum += a[i];
  }
}
void precalc() {
  dp[0][0][0] = 1;
  a.push_back(-1);
  sort(a.begin(), a.end());
  a.erase(unique(a.begin(), a.end()), a.end());
  m = a.size() - 1;
  for (int i = 1; i <= m; ++i) {
    int el = a[i];
    dp[i][0][0] = 1;
    for (int j = 1; j <= n; ++j) {
      for (int w = 1; w <= sum; ++w) {
        maxEl[i][j][w] = -1;
        for (int t = 0; t <= cnt[el] && t <= j && w >= el * t; ++t) {
          if (dp[i][j][w] == 2) {
            break;
          }
          dp[i][j][w] = min(2, dp[i][j][w] + dp[i - 1][j - t][w - el * t]);
          if (dp[i - 1][j - t][w - el * t]) {
            maxEl[i][j][w] = t;
          }
        }
      }
    }
  }
}
void solve() {
  read();
  precalc();
  int it = a.size() ^ 1;
  for (int k = 1; k <= n; ++k) {
    for (int wt = 1; wt <= sum; ++wt) {
      if (dp[m][k][wt] == 0 || dp[m][k][wt] == 2) {
        continue;
      }
      memcpy(bufcnt, cnt, sizeof cnt);
      int maxik = -1, minik = 1e9;
      int j = k, w = wt;
      for (int i = m; i > 0; --i) {
        int tmp = maxEl[i][j][w];
        if (tmp == -1 || tmp == 0) {
          continue;
        }
        bufcnt[a[i]] -= tmp;
        maxik = max(maxik, a[i]);
        minik = min(minik, a[i]);
        w -= tmp * a[i];
        j -= tmp;
      }
      int res = 0, tmp = 0;
      for (int i = 1; i <= 100; ++i) {
        if (bufcnt[i] > 0) {
          ++tmp;
        }
      }
      res = k * (maxik == minik) + (n - k) * (tmp <= 1);
      ans = max(ans, res);
    }
  }
  cout << ans;
}
int main() {
  ios::sync_with_stdio(0);
  cout.tie(0), cin.tie(0);
  solve();
  return 0;
}
