#include <bits/stdc++.h>
using namespace std;
const int maxn = 101;
int a[maxn];
int n;
int cnt[maxn], mx;
void enter() {
  cin >> n;
  for (int i = (1), _b = (n + 1); i < _b; ++i) {
    cin >> a[i];
    mx = max(mx, a[i]);
    cnt[a[i]]++;
  }
}
int f[maxn][maxn * maxn];
const int mod = 1e9 + 7;
void solve() {
  f[0][0] = 1;
  for (int w = (1), _b = (mx + 1); w < _b; ++w) {
    for (int i = n; i >= 1; --i) {
      for (int k = cnt[w]; k >= 1; --k)
        for (int j = mx * n; j >= 1; --j) {
          if (j == 200) cerr << "";
          if (i >= k && j >= w * k) f[i][j] += f[i - k][j - w * k];
        }
    }
  }
  int ans = 0;
  for (int i = (1), _b = (mx + 1); i < _b; ++i) {
    for (int j = (1), _b = (cnt[i] + 1); j < _b; ++j) {
      if (f[j][i * j] == 1) ans = max(ans, j);
    }
  }
  cout << ans;
}
bool check() {
  sort(a + 1, a + n + 1);
  int d = 0;
  for (int i = (2), _b = (n + 1); i < _b; ++i)
    if (a[i] != a[i - 1]) ++d;
  if (d <= 1)
    return true;
  else
    return false;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  enter();
  if (check())
    cout << n;
  else
    solve();
}
