#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int n, g, a, f[2][N][N * N], cnt[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a);
    cnt[a]++;
    if (cnt[a] == 1) g++;
  }
  f[0][0][0] = 1;
  int sum = 0, t = 0;
  for (int i = 1; i <= 100; i++, t ^= 1) {
    memset(f[t ^ 1], 0, sizeof f[t ^ 1]);
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= sum; k++) {
        if (!f[t][j][k]) continue;
        for (int p = 0; p <= cnt[i]; p++) {
          int &r = f[t ^ 1][j + p][k + i * p];
          if (f[t][j][k] == -1)
            r = -1;
          else {
            if (!r)
              r = 1;
            else
              r = -1;
          }
        }
      }
    }
    sum += i * cnt[i];
  }
  int ans = 0;
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= cnt[i]; j++) {
      if (f[t][j][j * i] == 1) {
        ans = max(ans, (g == 2 && j == cnt[i]) ? n : j);
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
