#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 100;
int dp[N][102], a[102], b[102], c[102][102];
int main() {
  int n, E = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (b[a[i]] == 0) {
      E++;
    }
    b[a[i]]++;
  }
  if (E == 1) {
    cout << n;
    return 0;
  }
  if (E == 2) {
    cout << n;
    return 0;
  }
  c[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    c[i][0] = c[i][i] = 1;
    for (int j = 1; j < i; j++) {
      c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
    }
  }
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = i * 100; j >= 0; j--) {
      for (int k = 0; k < i; k++) {
        dp[j + a[i]][k + 1] += dp[j][k];
      }
    }
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= b[a[i]]; j++) {
      if (dp[j * a[i]][j] == c[b[a[i]]][j]) {
        cnt = max(cnt, j);
      }
    }
  }
  cout << cnt;
}
