#include <bits/stdc++.h>
using namespace std;
const int P = 1e9 + 7;
const int N = 105, M = 10005;
const double pi = acos(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int a[N], num[N], f[N][M], g[N][M];
int n, m, nm;
bool flag = false;
int main() {
  cin >> n;
  for (int i = (1); i <= (n); ++i) cin >> a[i], num[a[i]]++;
  sort(a + 1, a + n + 1);
  for (int i = (1); i <= (n); ++i) m += (a[i] != a[i - 1]);
  if (m == 1) {
    cout << n << endl;
    return 0;
  }
  if (m == 2) flag = true;
  f[0][0] = 1;
  m = nm = 0;
  for (int w = (1); w <= (100); ++w)
    if (num[w]) {
      swap(f, g);
      for (int j = (0); j <= (nm); ++j)
        for (int k = (0); k <= (m); ++k) f[j][k] = 0;
      m += w * num[w], nm += num[w];
      for (int i = (num[w]); i >= (0); --i) {
        for (int j = (nm); j >= (i); --j)
          for (int k = (m); k >= (w * i); --k) {
            f[j][k] = min(10, f[j][k] + g[j - i][k - w * i]);
          }
      }
    }
  int ans = 1;
  for (int w = (1); w <= (100); ++w)
    for (int i = (1); i <= (num[w]); ++i)
      if (f[i][w * i] == 1) ans = max(ans, i);
  if (flag) {
    int c = 0;
    for (int i = (1); i <= (n); ++i)
      if (a[i] == a[1]) c++;
    if (f[c][c * a[1]] == 1 && f[n - c][(n - c) * a[n]] == 1) ans = n;
  }
  cout << ans << endl;
  return 0;
}
