#include <bits/stdc++.h>
using namespace std;
int N;
int A[105];
bool DP[105][10005];
typedef struct {
  int i, j;
} pos_t;
bool reachable(int step, int count) {
  int weight = step * count;
  for (int i = 0; i < 105; i++) {
    for (int j = 0; j < 10005; j++) {
      DP[i][j] = false;
    }
  }
  int S[105];
  int SL = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] != step) S[SL++] = A[i];
  }
  for (int i = 0; i < count - 1; i++) {
    S[SL++] = step;
  }
  DP[0][0] = true;
  vector<pos_t> positions;
  positions.push_back({0, 0});
  for (int i = 0; i < SL; i++) {
    int size = positions.size();
    for (int j = 0; j < size; j++) {
      pos_t pos = positions[j];
      int new_i = pos.i + 1;
      int new_j = pos.j + S[i];
      if (new_i < 105 && new_j < 10005 && !DP[new_i][new_j]) {
        DP[new_i][new_j] = true;
        positions.push_back({new_i, new_j});
      }
    }
  }
  return DP[count][step * count];
}
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  set<int> distincts;
  multiset<int> all;
  for (int i = 0; i < N; i++) {
    distincts.insert(A[i]);
    all.insert(A[i]);
  }
  if (distincts.size() == 2) {
    cout << N << endl;
    exit(0);
  }
  int answer = 1;
  for (auto it = distincts.begin(); it != distincts.end(); it++) {
    int step = *it;
    int count = all.count(step);
    for (int i = 2; i <= count; i++) {
      if (!reachable(step, i)) {
        answer = max(answer, i);
      }
    }
  }
  cout << answer << endl;
}
