#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
const int maxn = 110;
inline char gc() {
  return getchar();
  static const int maxs = 1 << 16;
  static char buf[maxs], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, maxs, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline long long rd() {
  long long x = 0;
  char c = gc();
  bool neg = 0;
  while (c < '0' || c > '9') {
    if (c == '-') neg = 1;
    c = gc();
  }
  while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + c - '0', c = gc();
  return neg ? (~x + 1) : x;
}
bitset<10050> f[maxn];
int a[maxn], N, cnt[maxn];
int main() {
  int i, j, k;
  N = rd();
  int sum = 0;
  for (i = 1; i <= N; i++) a[i] = rd(), cnt[a[i]]++, sum += a[i];
  sort(a + 1, a + N + 1);
  int ans = 1;
  if (cnt[a[1]] + cnt[a[N]] == N) {
    printf("%d\n", N);
    return 0;
  }
  for (i = 1; i <= N; i++) {
    if (a[i] != a[i - 1]) {
      for (j = 0; j <= N; j++) f[j].reset();
      f[0][0] = 1;
      for (j = 1; j <= N; j++) {
        if (a[j] == a[i]) continue;
        for (k = j - 1; k >= 0; k--) {
          f[k + 1] |= f[k] << a[j];
        }
      }
      for (j = 1; j <= cnt[a[i]]; j++) {
        if (f[j][a[i] * j]) break;
      }
      j--;
      ans = max(ans, j);
    }
  }
  printf("%d\n", ans);
  return 0;
}
