#include <bits/stdc++.h>
using namespace std;
int n, m;
const int N = 10000;
const int mod = 1000 * 1000 * 1000 + 7;
int a[200];
int cnt[200];
int dp[200][N + 5];
int choose[300][300];
set<int> d;
void Choose() {
  choose[0][0] = 1;
  for (int i = 1; i < 200; i++) {
    choose[i][0] = 1;
    for (int j = 1; j < 200; j++) {
      choose[i][j] = choose[i - 1][j - 1] + choose[i - 1][j];
      choose[i][j] = choose[i][j] % mod;
    }
  }
}
int main() {
  Choose();
  cin >> n;
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    d.insert(a[i]);
    cnt[a[i]]++;
  }
  if (d.size() < 3) {
    cout << n;
    exit(0);
  }
  for (int k = 0; k < n; k++) {
    for (int i = n; i >= 1; i--) {
      for (int j = 0; j <= N; j++) {
        dp[i][j] += dp[i - 1][j - a[k]];
      }
    }
  }
  int ans = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= cnt[a[i]]; j++) {
      if (dp[j][j * a[i]] == choose[cnt[a[i]]][j]) {
        ans = max(ans, j);
      }
    }
  }
  cout << ans << endl;
}
