#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a;
int cnt[101];
int memo[10001][101];
int sum = 0;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    sum += x;
    cnt[x]++;
    a.push_back(x);
  }
  sort(a.begin(), a.end());
  vector<int>::iterator it = unique(a.begin(), a.end());
  a.resize(it - a.begin());
  if (a.size() <= 2) {
    cout << n;
    return 0;
  }
  int res = 0;
  for (int i = 0; i <= 10000; i++)
    for (int j = 0; j <= 100; j++) memo[i][j] = -1;
  memo[0][0] = 0;
  for (int i = 0; i < a.size(); i++)
    for (int j = sum; j >= 0; j--)
      for (int k = n; k >= 0; k--)
        if (memo[j][k] != -1) {
          for (int z = 1; z <= cnt[a[i]]; z++) {
            if (j + z * a[i] <= sum)
              memo[j + z * a[i]][k + z] = min(2, memo[j][k] + 1);
            else
              break;
          }
        }
  for (int i = 0; i < a.size(); i++) {
    int cur = a[i];
    for (int j = 1; j <= cnt[cur]; j++) {
      int z = memo[cur * j][j];
      if (z == 1) res = max(res, j);
    }
  }
  cout << res;
}
