#include <bits/stdc++.h>
using namespace std;
const int mo = 1e9 + 7;
int n, a[101], f[10001][101], c[101][101];
int main() {
  scanf("%d", &n);
  for (int i = 0; i <= n; i++) {
    c[i][0] = 1;
    for (int j = 1; j <= i; j++) c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mo;
  }
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  f[0][0] = 1;
  int s = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = s; j >= 0; j--)
      for (int k = 0; k <= i - 1; k++)
        f[j + a[i]][k + 1] = (f[j + a[i]][k + 1] + f[j][k]) % mo;
    s += a[i];
  }
  int ans = 0;
  sort(a + 1, a + n + 1);
  int la = 1;
  int co = 0;
  for (int i = 2; i <= n + 1; i++)
    if (i > n || a[i] != a[i - 1]) co++;
  for (int i = 2; i <= n + 1; i++)
    if (i > n || a[i] != a[i - 1]) {
      int g = i - la;
      for (int j = 1; j <= g; j++)
        if (f[a[i - 1] * j][j] == c[g][j]) ans = ans > j ? ans : j;
      if (co == 2 && f[a[i - 1] * g][g] == 1) ans = n;
      la = i;
    }
  printf("%d", ans);
}
