#include <bits/stdc++.h>
using namespace std;
const int N = 105, A = 105;
int n;
int a[N], cnt[N];
bool ways[N * A][N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  set<int> second;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
    second.insert(a[i]);
  }
  if (((int)(second).size()) <= 2) {
    cout << n << endl;
    return 0;
  }
  ways[0][0] = true;
  int mx = 1;
  for (int w = 1; w < A; w++) {
    if (cnt[w] > 0) {
      for (int x = 0; x < N * A; x++)
        fill(ways[x] + 1, ways[x] + cnt[w] + 1, false);
      for (int i = 0; i < n; i++) {
        if (a[i] != w) {
          for (int x = N * A - 1; x >= a[i]; x--) {
            for (int k = 1; k <= cnt[w]; k++) {
              ways[x][k] |= ways[x - a[i]][k - 1];
            }
          }
        }
      }
      for (int j = 1; j <= cnt[w] && !ways[w * j][j]; j++) {
        mx = max(mx, j);
      }
    }
  }
  cout << mx << '\n';
}
