#include <bits/stdc++.h>
using namespace std;
const int N = 101;
bitset<N * N> dp[N];
int arr[N], F[N];
int main() {
  int n, cnt = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    cnt += (F[arr[i]] == 0);
    ++F[arr[i]];
  }
  sort(arr + 1, arr + n + 1);
  if (cnt <= 2) {
    cout << n << endl;
    return 0;
  }
  int MAX = 1;
  for (int i = 1; i <= 100; i++) {
    for (int j = MAX + 1; j <= F[i]; j++) {
      for (int k = 1; k <= 100; k++) dp[k].reset();
      dp[0][0] = 1;
      for (int k = 1; k <= n; k++) {
        if (arr[k] == i) continue;
        for (int l = n; l > 0; l--) {
          dp[l] |= dp[l - 1] << arr[k];
        }
      }
      for (int k = 1; k < j; k++) {
        for (int l = n; l > 0; l--) {
          dp[l] |= dp[l - 1] << i;
        }
      }
      if (!dp[j][j * i]) {
        MAX = j;
      }
    }
  }
  cout << MAX << endl;
}
