#include <bits/stdc++.h>
using namespace std;
const int maxn = 120;
const int maxm = 10020;
const int MOd = 998244353;
int a, b, c;
int dn[maxn][maxm];
int num[maxn], ar[maxn], tot;
int main() {
  scanf("%d", &a);
  int maxi = 0, ss = 0;
  for (int i = 1; i <= a; i++) {
    scanf("%d", &ar[i]);
    tot += ar[i];
    maxi = max(maxi, (ar[i]));
    num[ar[i]]++;
    if (num[ar[i]] == 1) ss++;
  }
  if (ss <= 2) {
    printf("%d\n", a);
    return 0;
  }
  dn[0][0] = 1;
  int s = 0;
  for (int i = 1; i <= maxi; i++) {
    if (!num[i]) continue;
    int val = i;
    for (int j = tot - val * num[i]; j >= 0; j--)
      for (int k = 1; k <= s; k++)
        if (dn[k][j]) {
          for (int h = 1; h <= num[i]; h++) {
            dn[k + h][j + val * h] += dn[k][j];
            if (dn[k + h][j + val * h] > 2) dn[k + h][j + val * h] = 2;
          }
        }
    s += num[i];
    for (int h = 1; h <= num[i]; h++) dn[h][val * h]++;
  }
  int ans = 0;
  for (int i = 1; i <= a; i++)
    for (int j = 0; j <= tot; j++) {
      if (dn[i][j] == 1 && j % i == 0 && num[j / i] >= i) ans = max(ans, (i));
    }
  cout << ans << endl;
  return 0;
}
