#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-6;
const double PI = acos(-1.0);
const int MOD = 1000000007;
const int MAXN = 105;
int a[MAXN];
int c[20000][101];
int cnt[101];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
  int n;
  cin >> n;
  c[0][0] = -1;
  int sum = 0;
  for (int i = 0; i < (int)(n); i++) {
    cin >> a[i];
    sum += a[i];
    cnt[a[i]]++;
    for (int j = (int)10002; j >= (int)(0); j--) {
      for (int k = 0; k < (int)(101); k++) {
        if (c[j][k] > 0) {
          if (c[j][k] == a[i] &&
              (c[j + a[i]][k + 1] == 0 || c[j + a[i]][k + 1] == a[i])) {
            c[j + a[i]][k + 1] = a[i];
          } else {
            c[j + a[i]][k + 1] = -2;
          }
        }
        if (c[j][k] == -2) {
          c[j + a[i]][k + 1] = -2;
        }
        if (c[j][k] == -1) {
          if (c[j + a[i]][k + 1] != 0 && c[j + a[i]][k + 1] != a[i]) {
            c[j + a[i]][k + 1] = -2;
          } else {
            c[j + a[i]][k + 1] = a[i];
          }
        }
      }
    }
  }
  int res = 0;
  sort(a, a + n);
  for (int i = 0; i < (int)(101); i++) {
    for (int j = 0; j < (int)(cnt[i] + 1); j++) {
      if (c[i * j][j] == i) {
        res = max(res, j);
        if (c[sum - i * j][n - j] > 0) {
          res = n;
        }
      }
    }
  }
  cout << res << "\n";
  return 0;
}
