#include <bits/stdc++.h>
using namespace std;
const int N = 111, mod = 1e9 + 7;
long long a[N], cnt[N], ts, f[N * N][N], c[N][N];
void init() {
  for (int i = 0; i < N; i++)
    for (int j = 0; j <= i; j++)
      if (!j)
        c[i][j] = 1;
      else
        c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
}
int main() {
  init();
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (!cnt[a[i]]) ts++;
    cnt[a[i]]++;
  }
  if (ts <= 2)
    cout << n << endl;
  else {
    int res = 0;
    f[0][0] = 1;
    for (int i = 1; i <= n; i++) {
      for (int j = 10000; j >= a[i]; j--)
        for (int k = 1; k <= i; k++) {
          f[j][k] = (f[j][k] + f[j - a[i]][k - 1]) % mod;
        }
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= cnt[a[i]]; j++)
        if (f[j * a[i]][j] == c[cnt[a[i]]][j]) res = max(res, j);
    }
    cout << res << endl;
  }
}
