#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                         {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};
int main() {
  int n;
  int a[102];
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  int cnt[102] = {};
  for (int i = 1; i <= n; i++) {
    cnt[a[i]]++;
  }
  int ret = 1;
  for (int m = 1; m <= 100; m++) {
    if (cnt[m] <= 1) continue;
    static bitset<10010> dp[102];
    for (int j = 0; j < 102; j++) {
      dp[j].reset();
    }
    dp[0][0] = true;
    for (int i = 1; i <= n; i++) {
      if (a[i] == m) continue;
      for (int j = cnt[m]; j >= 1; j--) {
        dp[j] |= (dp[j - 1] << a[i]);
      }
    }
    for (int i = 2; i <= cnt[m]; i++) {
      if (dp[i][i * m]) break;
      ret = max(ret, i);
    }
  }
  int CNT = 0;
  for (int m = 1; m <= 100; m++) {
    if (cnt[m] > 0) CNT++;
  }
  if (CNT <= 2) {
    cout << n << endl;
  } else {
    cout << ret << endl;
  }
}
