#include <bits/stdc++.h>
using namespace std;
int vis[10101];
int a[1010], sum[1010];
const int INF = 998244353;
int c[1010][1010];
int f[101][10101];
int main() {
  int n, i, j, ans = 0, summ = 0, k, sum2 = 0;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    summ += a[i];
    sum[a[i]]++;
    if (sum[a[i]] == 1) sum2++;
  }
  c[0][0] = 1;
  for (i = 1; i <= 105; i++) {
    c[i][0] = 1;
    for (j = 1; j <= 105; j++) c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % INF;
  }
  sort(a + 1, a + n + 1);
  f[0][0] = 1;
  for (i = 1; i <= n; i++) {
    for (j = n; j >= 1; j--) {
      for (k = summ; k >= a[i]; k--)
        f[j][k] = (f[j][k] + f[j - 1][k - a[i]]) % INF;
    }
  }
  for (i = 1; i <= 100; i++) {
    for (j = 1; j <= sum[i]; j++) {
      if (f[j][j * i] == c[sum[i]][j]) {
        if (sum2 == 2 && j == sum[i])
          ans = n;
        else
          ans = max(ans, j);
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
