#include <bits/stdc++.h>
using namespace std;
const int MX = 101;
const long long inf = (1ll << 61);
int n, a[MX], b[MX], b1[MX];
int N, S;
short int dp[MX][MX][MX * MX / 2];
short int DP(int num, int x, int y) {
  if (num > 100) return 0;
  if (x < 0) return 0;
  if (y < 0) return 0;
  if (x == 0) return (y == 0);
  short int &ret = dp[num][x][y];
  if (ret != -1) return ret;
  ret = 0;
  for (int i = 0; i <= b[num]; i++) {
    ret += (ret, DP(num + 1, x - i, y - i * num));
    if (ret > 2) ret = 2;
  }
  return ret;
}
int main() {
  cin >> n;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (b[a[i]] == 0) sum++;
    b[a[i]]++;
  }
  if (sum <= 2) {
    cout << n << endl;
    return 0;
  }
  int ans = 1;
  memset(dp, -1, sizeof(dp));
  for (int i = 1; i <= 100; i++) {
    if (i * b[i] > 5000) {
      ans = max(ans, b[i]);
      continue;
    }
    for (int k = 2; k <= b[i]; k++) {
      if (DP(1, k, i * k) == 1) ans = max(ans, k);
    }
  }
  cout << ans << endl;
}
