#include <bits/stdc++.h>
using namespace std;
const int maxN = 111;
int n, a[maxN], f[maxN][maxN * maxN], s[maxN][maxN * maxN], cnt[maxN], r;
vector<int> v;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    ++cnt[a[i]];
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; ++i)
    if (a[i] != a[i - 1]) v.push_back(a[i]);
  if (v.size() <= 2) {
    cout << n;
    return 0;
  }
  f[0][0] = 1;
  for (int i = 1; i <= 100; ++i) {
    for (int dem = 0; dem <= 100; ++dem)
      for (int sum = 0; sum <= 100 * 100; ++sum) s[dem][sum] = f[dem][sum];
    for (int j = 1; j <= cnt[i]; ++j)
      for (int dem = j; dem <= n; ++dem)
        for (int sum = i * j; sum <= 100 * 100; ++sum)
          f[dem][sum] = min(2, f[dem][sum] + s[dem - j][sum - i * j]);
  }
  for (int k = n; k >= 1; --k)
    for (int j : v) {
      if (f[k][j * k] == 1 && cnt[j] >= k) {
        cout << k;
        return 0;
      }
    }
}
