#include <bits/stdc++.h>
using namespace std;
int n, ans = 0;
int vals[110];
map<int, int> freq;
long long knapsack[10010][110];
long long choose[110][110];
int main() {
  scanf("%d", &n);
  int KNAP = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &vals[i]);
    freq[vals[i]]++;
    KNAP += vals[i];
  }
  KNAP++;
  if (freq.size() <= 2) {
    printf("%d\n", n);
    return 0;
  }
  for (int i = 0; i < KNAP; i++)
    for (int j = 0; j <= n; j++) knapsack[i][j] = 0;
  knapsack[0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = n; j >= 1; j--) {
      for (int k = KNAP - 1; k >= vals[i]; k--) {
        knapsack[k][j] = knapsack[k][j] + knapsack[k - vals[i]][j - 1];
        knapsack[k][j] %= 29996224275833;
      }
    }
  }
  for (int i = 1; i <= n; i++) choose[i][0] = 1, choose[i][i] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j < i; j++) {
      choose[i][j] = choose[i - 1][j] + choose[i - 1][j - 1];
      choose[i][j] %= 29996224275833;
    }
  }
  int ans = 0;
  for (auto i : freq) {
    for (int j = 1; j <= i.second; j++) {
      long long expect = choose[i.second][j];
      if (expect == knapsack[j * i.first][j])
        ans = max(ans, j);
      else
        break;
    }
  }
  printf("%d\n", ans);
}
