#include <bits/stdc++.h>
using namespace std;
struct __s {
  __s() {
    if (1) {
      ios_base::Init i;
      cin.sync_with_stdio(0);
      cin.tie(0);
    }
  }
  ~__s() {
    if (!1)
      fprintf(stderr, "Execution time: %.3lf s.\n",
              (double)clock() / CLOCKS_PER_SEC);
    long long n;
    cin >> n;
  }
} __S;
struct DP {
  long long mn;
  long long mx;
  long long idx;
  DP(long long mn_, long long mx_, long long idx_)
      : mn(mn_), mx(mx_), idx(idx_) {}
};
long long a[111];
vector<DP> dp[111][11111][2];
bool check(long long x, long long y) {
  if (dp[x][y][0].size()) return false;
  if (dp[x][y][1].size()) return true;
  return false;
}
int main(void) {
  long long n;
  cin >> n;
  long long sum = 0;
  for (long long i = 0; i < (long long)(n); i++) {
    cin >> a[i];
    sum += a[i];
  }
  dp[0][0][0].push_back(DP(1e9, 0, -1));
  dp[0][0][1].push_back(DP(1e9, 0, -1));
  for (long long i = 0; i < (long long)(n); i++) {
    for (long long _ = 0; _ < (long long)(n); _++) {
      for (long long j = 0; j < (long long)(sum); j++) {
        for (long long k = 0; k < (long long)(2); k++) {
          for (auto p : dp[_][j][k]) {
            if (p.idx >= i) continue;
            long long l =
                (p.mn == p.mx && p.mn == a[i] || p.mn == 1e9 && p.mx == 0);
            if (dp[_ + 1][j + a[i]][l].size() < 2) {
              dp[_ + 1][j + a[i]][l].push_back(
                  {min(p.mn, a[i]), max(p.mx, a[i]), max(p.idx, i)});
            }
          }
        }
      }
    }
  }
  long long ans = 1;
  for (long long i = 1; i <= n; ++i) {
    for (long long j = 1; j <= sum; ++j) {
      long long x = n - i;
      long long y = sum - j;
      long long res = 0;
      if (check(i, j)) res += i;
      if (check(x, y)) res += x;
      ans = max(ans, res);
    }
  }
  cout << ans << '\n';
  return 0;
}
