#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int f[N][N * N], n, a[N], kinds, tot[N], lim, C[N][N], ans = 1;
int read() {
  int x = 0, f = 1;
  char s;
  while ((s = getchar()) > '9' || s < '0')
    if (s == '-') f = -1;
  while (s >= '0' && s <= '9')
    x = (x << 1) + (x << 3) + (s ^ 48), s = getchar();
  return x * f;
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) {
    a[i] = read(), ++tot[a[i]], lim += a[i];
    if (tot[a[i]] == 1) ++kinds;
  }
  if (kinds <= 2) return printf("%d\n", n), 0;
  f[0][0] = 1;
  for (int i = 1; i <= n; ++i)
    for (int j = lim; j >= a[i]; --j)
      for (int k = n; k; --k) f[k][j] += f[k - 1][j - a[i]];
  for (int i = 0; i <= n; ++i) {
    C[i][0] = C[i][i] = 1;
    for (int j = 0; j < i; ++j) C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
  }
  for (int i = 1; i <= 100; ++i)
    for (int j = 2; j <= tot[i]; ++j)
      if (f[j][j * i] == C[tot[i]][j]) ans = max(ans, j);
  printf("%d\n", ans);
  return 0;
}
