#include <bits/stdc++.h>
using namespace std;
const int N = 110, M = 11000;
int n, buc[N];
bitset<M> f[N];
template <class T>
inline void read(T &x) {
  x = 0;
  char ch = getchar(), w = 0;
  while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  x = w ? -x : x;
  return;
}
int main() {
  int x, lim = 0, ans = 0;
  read(n);
  for (register int i = 1; i <= n; ++i) read(x), ++buc[x], lim = max(lim, x);
  for (register int i = 1; i < lim; ++i)
    if (buc[i] == n - buc[lim]) return printf("%d\n", n), 0;
  for (register int i = 1; i <= lim; ++i) {
    if (!buc[i]) continue;
    for (register int j = 0; j <= buc[i]; ++j) f[j].reset();
    f[0][0] = 1;
    for (register int j = 1; j <= lim; ++j) {
      if (j == i) continue;
      for (register int k = 1; k <= buc[j]; ++k)
        for (register int l = buc[i]; l; --l) f[l] |= f[l - 1] << j;
    }
    for (register int j = 1; j <= buc[i]; ++j) {
      if (!f[j][i * j]) ans = max(ans, j);
      for (register int l = buc[i]; l; --l) f[l] |= f[l - 1] << i;
    }
  }
  cout << ans << endl;
  return 0;
}
