#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ld = long double;
const ld EPS = 1e-9;
const ll MOD[3] = {(int)1e9 + 7, 998244353, 999939953};
const ld PI = 3.141592653589793;
const int maxn = 1e6 + 1;
using pt = array<ld, 2>;
int dp[3][101][10001];
int a[101];
int C[3][101][101];
int add(int a, int b, int mod) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
  return a;
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.precision(10);
  cout << fixed;
  cin.tie(0);
  int n;
  cin >> n;
  for (int tp = 0; tp < 3; ++tp) {
    C[tp][0][0] = 1;
    for (int i = 1; i <= n; ++i) {
      C[tp][i][0] = 1;
      C[tp][i][i] = 1;
      for (int j = 1; j < n; ++j) {
        C[tp][i][j] = add(C[tp][i - 1][j - 1], C[tp][i - 1][j], MOD[tp]);
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  map<int, int> xx;
  for (int i = 1; i <= n; ++i) {
    xx[a[i]]++;
  }
  if (xx.size() <= 2) {
    cout << n;
    return 0;
  }
  sort(a + 1, a + 1 + n);
  for (int tp = 0; tp < 3; ++tp) {
    dp[tp][0][0] = 1;
    for (int j = 1; j <= n; ++j) {
      for (int e = n; e >= 1; --e) {
        for (int sum = 0; sum <= 10000; ++sum) {
          if (sum >= a[j]) {
            dp[tp][e][sum] =
                add(dp[tp][e - 1][sum - a[j]], dp[tp][e][sum], MOD[tp]);
          }
        }
      }
    }
  }
  int ans = 1;
  for (auto it : xx) {
    for (int cnt = 1; cnt <= it.second; ++cnt) {
      int cur_sum = cnt * it.first;
      bool ok = true;
      for (int tp = 0; tp < 3; ++tp) {
        if (dp[tp][cnt][cur_sum] != C[tp][it.second][cnt]) {
          ok = false;
        }
      }
      if (ok) {
        ans = max(ans, cnt);
      }
    }
  }
  cout << ans;
}
