#include <bits/stdc++.h>
const int maxn = 110;
int n, a[maxn], w[maxn], c[maxn], cnt, ans, f[maxn][maxn * maxn];
void chkmax(int &a, int b) { a = a > b ? a : b; }
int in() {
  int re = 0;
  char c = getchar();
  bool f = 0;
  while (c < '0' || c > '9') f |= (c == '-'), c = getchar();
  while (c >= '0' && c <= '9')
    re = (re << 1) + (re << 3) + (c ^ '0'), c = getchar();
  return f ? -re : re;
}
int main() {
  int tot = 0, s = 0;
  n = in();
  for (int i = 1; i <= n; ++i) a[i] = in();
  std::sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n; ++i)
    if (a[i] != a[i - 1]) {
      w[++cnt] = a[i];
      c[cnt] = 1;
    } else
      ++c[cnt];
  if (cnt <= 2) {
    printf("%d", n);
    return 0;
  }
  f[0][0] = 1;
  for (int i = 1; i <= cnt; ++i) {
    for (int j = tot; j >= 0; --j)
      for (int k = 0; k <= s; ++k)
        for (int o = 1; o <= c[i]; ++o) f[j + o][k + o * w[i]] += f[j][k];
    tot += c[i];
    s += c[i] * w[i];
  }
  for (int i = 1; i <= cnt; ++i)
    for (int j = 1; j <= c[i]; ++j)
      if (f[j][w[i] * j] == 1) chkmax(ans, j);
  printf("%d", ans);
  return 0;
}
