#include <bits/stdc++.h>
using namespace std;
const int N = 105;
const int inf = 1e9 + 5;
int f[N][N * N], g[N][N * N], n;
map<int, int> cnta;
int main() {
  cin >> n;
  f[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    cnta[a]++;
    for (int j = i - 1; j >= 0; j--) {
      for (int k = 0; k < N * N; k++) {
        if (f[j][k]) {
          f[j + 1][k + a] = 1;
          if ((k + a) % (j + 1) == 0 && j * a != k) {
            g[j + 1][k + a] = 1;
          }
        }
      }
    }
  }
  if (cnta.size() <= 2) {
    cout << n << endl;
    return 0;
  }
  int ans = 1;
  for (auto pr : cnta) {
    for (int j = 2; j <= pr.second; j++) {
      if (!g[j][pr.first * j])
        ans = max(ans, j);
      else
        break;
    }
  }
  cout << ans << endl;
  return 0;
}
