#include <bits/stdc++.h>
using namespace std;
const long long N = 10001, K = 101;
long long dp[N][K];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  vector<long long> a(n + 1);
  set<long long> s;
  for (long long i = 1; i <= n; ++i) cin >> a[i], s.insert(a[i]);
  for (long long i = 1; i <= n; ++i) {
    for (long long k = n; k >= 1; --k) {
      for (long long j = N - 1; j >= 1; --j) {
        if (j == a[i]) {
          if (k == 1 && (dp[j][k] == 0 || dp[j][k] == a[i]))
            dp[j][k] = a[i];
          else
            dp[j][k] = 0;
        } else if (j > a[i]) {
          if (dp[j - a[i]][k - 1]) {
            if (dp[j - a[i]][k - 1] == a[i]) {
              if (dp[j][k] == 0 || dp[j][k] == a[i])
                dp[j][k] = a[i];
              else
                dp[j][k] = K;
            } else
              dp[j][k] = K;
          }
        }
      }
    }
  }
  long long ans = 0;
  for (long long i = 1; i < N; ++i) {
    for (long long j = 1; j <= n; ++j)
      if (dp[i][j] && dp[i][j] != K) {
        ans = max(ans, j);
      }
  }
  if (s.size() == 2)
    cout << n << "\n";
  else
    cout << ans << "\n";
}
