#include <bits/stdc++.h>
using namespace std;
const int N = 110, M = 1e4 + 10, oo = (1 << 30) - 1;
int f[N][M], a[N], n;
int main() {
  scanf("%d", &n);
  for (int i = 0, x; i < n; ++i) {
    scanf("%d", &x);
    ++a[x];
  }
  int variy = 0;
  for (int i = 1; i <= 100; ++i) variy += (a[i] > 0);
  if (variy <= 2) return printf("%d\n", n), 0;
  f[0][0] = 1;
  for (int i = 1; i <= 100; ++i)
    for (int j = M - 1; j >= i; --j)
      for (int t = 100; ~t; --t)
        for (int k = 1; k <= a[i] && k * i <= j && k <= t; ++k)
          f[t][j] = min(oo, f[t][j] + f[t - k][j - k * i]);
  int ans = 0;
  for (int i = 1; i <= 100; ++i)
    for (int j = 1; j <= a[i]; ++j)
      if (f[j][i * j] == 1) ans = max(ans, j);
  printf("%d\n", ans);
  return 0;
}
