#include <bits/stdc++.h>
using namespace std;
const int N = 101;
const int M = 10001;
const long long m1 = hash<string>()("          	");
const long long m2 = hash<string>()("	          ");
const long long mod = INT_MAX * m1 + m2;
int n, w[N], cnt[N];
long long ways[N][M];
long long choose[N][N];
int main() {
  choose[0][0] = 1;
  for (int i = 1; i < N; i++) {
    for (int j = 0; j <= i; j++) {
      if (j > 0) choose[i][j] += choose[i - 1][j - 1];
      if (j < i) choose[i][j] += choose[i - 1][j];
      choose[i][j] %= mod;
    }
  }
  scanf("%d", &n);
  int dnt = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", w + i);
    if (cnt[w[i]]++ == 0) dnt++;
  }
  sort(w, w + n);
  ways[0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int u = n; u >= 1; u--) {
      for (int j = M - 1; j >= w[i]; j--) {
        ways[u][j] += ways[u - 1][j - w[i]];
        ways[u][j] %= mod;
      }
    }
  }
  int ans = 0;
  for (int v = 1; v < N; v++) {
    for (int j = 1; j <= cnt[v]; j++) {
      if (ways[j][v * j] == choose[cnt[v]][j]) {
        ans = max(ans, j);
        if (j == cnt[v] and dnt == 2) return !printf("%d\n", n);
      }
    }
  }
  cout << ans << endl;
}
