#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const long long LINF = (long long)INF * INF;
const int MAXN = 107;
const int MAXW = 10 * 1000 + 7;
int a[MAXN];
long long dp[2][MAXN][MAXW][2];
int main() {
  int n;
  cin >> n;
  set<int> S;
  for (int i = (0); i < (n); ++i) {
    cin >> a[i];
    S.insert(a[i]);
  }
  if ((int)((S).size()) == 1) {
    cout << n;
    return 0;
  }
  sort(a, a + n);
  dp[0][0][0][0] = 1;
  dp[0][1][a[0]][1] = 1;
  for (int i = (0); i < (n - 1); ++i) {
    for (int j = (0); j < (n); ++j)
      for (int sum = (0); sum < (MAXW); ++sum)
        for (int k = (0); k < (2); ++k) dp[(i + 1) & 1][j][sum][k] = 0;
    for (int j = (0); j < (i + 2); ++j) {
      int bound = j * MAXN + 7;
      for (int sum = (0); sum < (bound); ++sum)
        for (int k = (0); k < (2); ++k) {
          dp[(i + 1) & 1][j][sum][0] += dp[i & 1][j][sum][k];
          if (sum + a[i + 1] < MAXW && (k == 1 || a[i] != a[i + 1]))
            dp[(i + 1) & 1][j + 1][sum + a[i + 1]][1] += dp[i & 1][j][sum][k];
        }
    }
  }
  int cnt;
  int ans = 0;
  for (int i = (0); i < (n); ++i) {
    if (i == 0 || a[i] != a[i - 1]) cnt = 0;
    cnt++;
    if (dp[(n - 1) & 1][cnt][cnt * a[i]][0] +
            dp[(n - 1) & 1][cnt][cnt * a[i]][1] ==
        1) {
      if ((int)((S).size()) <= 2)
        ans = n;
      else
        ans = max(ans, cnt);
    }
  }
  cout << ans;
  return 0;
}
