#include <bits/stdc++.h>
const long long int MOD = 1e9 + 7;
const long long int INF = 1011111111;
const long long int LLINF = 1000111000111000111LL;
const long double EPS = 1e-10;
const long double PI = 3.14159265358979323;
using namespace std;
long long int power(long long int x, long long int n) {
  if (n == 0)
    return 1;
  else if (n % 2 == 0)
    return power((x * x), n / 2);
  else
    return x * power((x * x), (n - 1) / 2);
}
long long int dp[100005][105];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, m, i, j, k, y;
  cin >> n;
  long long int a[n], sum = 0;
  ;
  map<long long int, long long int> mp;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
    mp[a[i]]++;
  }
  dp[0][0];
  vector<long long int> coin, cnt;
  for (auto it = mp.begin(); it != mp.end(); ++it) {
    coin.push_back(it->first);
    cnt.push_back(it->second);
  }
  m = coin.size();
  if (m <= 2) return cout << n, 0;
  dp[0][0] = 1;
  for (i = 0; i < m; i++) {
    for (j = n; j >= 1; j--) {
      for (k = sum; k >= 0; k--) {
        long long int rem = min(j, cnt[i]);
        for (y = 1; y <= rem; y++) {
          if (k - coin[i] * y >= 0) dp[k][j] += dp[k - coin[i] * y][j - y];
          dp[k][j] = min(dp[k][j], 100LL);
        }
      }
    }
  }
  long long int ans = 1;
  for (i = 0; i <= sum; i++) {
    for (j = 0; j <= n; j++) {
      if (dp[i][j] == 1) {
        int f = 0;
        for (k = 0; k < m; k++) {
          if (j <= cnt[k] && i == j * coin[k]) f = 1;
        }
        if (f == 1) ans = max(ans, j);
      }
    }
  }
  cout << ans;
  cerr << '\n'
       << "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms"
       << '\n';
}
