#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
constexpr auto MOD = 1000000007LL;
constexpr auto LINF = (1LL << 60);
constexpr auto INF = 2147483647LL;
constexpr auto PI = 3.1415926535897932384626433;
constexpr auto EPS = 1E-9;
template <typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2> p) {
  out << p.first << ' ' << p.second;
  return out;
}
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& p) {
  in >> p.first >> p.second;
  return in;
}
template <typename T>
istream& operator>>(istream& in, vector<T>& v) {
  for (auto& x : v) in >> x;
  return in;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T> v) {
  for (int i = 0; i < v.size(); i++)
    out << v[i] << (i + 1 == v.size() ? '\n' : ' ');
  out.flush();
  return out;
}
int n, ways[110][10010], a[10010], res, sum;
map<int, int> m1;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    m1[a[i]]++;
  }
  if (m1.size() <= 2) {
    cout << n << endl;
    return 0;
  }
  ways[0][0] = 1;
  sort(a, a + n);
  for (int i = 0, j = 0; i < n; i = j) {
    while (j < n && a[i] == a[j]) j++;
    for (int k = i; k >= 0; k--) {
      for (int use = 1; use <= j - i; use++)
        for (int j = accumulate(a, a + k, 0); j <= sum; j++) {
          ways[k + use][j + a[i] * use] += ways[k][j];
          if (ways[k + use][j + a[i] * use] > 2)
            ways[k + use][j + a[i] * use] = 2;
        }
    }
    sum += a[i] * (j - i);
  }
  for (auto [v, c] : m1) {
    for (int i = 1; i <= c; i++) {
      if (ways[i][v * i] == 1) res = max(res, i);
    }
  }
  cout << res << endl;
  return 0;
}
