#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using vpll = vector<pll>;
using gr = vector<vll>;
using wgr = vector<vpll>;
struct d_ {
  template <typename T>
  d_ &operator,(const T &x) {
    cerr << ' ' << x;
    return *this;
  }
  template <typename T>
  d_ &operator,(const vector<T> &x) {
    for (auto x : x) cerr << ' ' << x;
    return *this;
  }
} d_t;
int A[107];
int cnt[107];
int n;
vll v;
char DP[107][107][107 * 107];
int dp(int cur, int num, int sum) {
  char &ret = DP[cur][num][sum];
  if (~ret) return ret;
  if (sum == 0 && num == 0) return ret = 1;
  if (cur == n) return ret = 0;
  if (num == 0) return ret = 0;
  ret = dp(cur + 1, num, sum);
  for (ll k = 1; k <= min(num, cnt[v[cur]]) && ret < 2 && sum - k * v[cur] >= 0;
       k++) {
    ret += dp(cur + 1, num - k, sum - k * v[cur]);
  }
  return ret = min(ret, char(2));
}
int main(void) {
  ios_base::sync_with_stdio(false);
  (memset(DP, -1, sizeof(DP)));
  ll N;
  cin >> N;
  set<ll> s;
  for (ll i(0); i < N; i++) {
    cin >> A[i];
    cnt[A[i]]++;
    s.insert(A[i]);
  }
  if (s.size() == 2) {
    cout << N << endl;
    return 0;
  }
  v = vll(begin(s), end(s));
  n = v.size();
  ll ret = 0;
  for (ll k(1); k < N + 1; k++)
    for (ll i(0); i < n; i++)
      if (cnt[v[i]] >= k) {
        ll rt = dp(0, k, k * v[i]);
        if (rt == 1) ret = k;
      }
  cout << ret << endl;
  return 0;
}
