#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18, MOD = 1e9 + 7;
const int N = 1e2 + 10, N2 = 2e9 + 10, INFI = 1e9 + 10, L = 19;
int n, a[N], dp[2][N * N][N], cnt[N], diff, sum;
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
    cnt[a[i]]++;
    if (cnt[a[i]] == 1) diff++;
  }
  if (diff <= 2) {
    cout << n << endl;
    return 0;
  }
  dp[0][0][0] = 1;
  for (int i = 1; i <= 100; i++) {
    dp[i & 1][0][0] = 1;
    for (int k = 0; k <= n; k++) {
      for (int w = 0; w <= sum; w++) {
        dp[i & 1][w][k] = 0;
        for (int c = 0; c <= cnt[i]; c++) {
          if (w - c * i >= 0 && k - c >= 0) {
            dp[i & 1][w][k] =
                min(2, dp[i & 1][w][k] + dp[(i - 1) & 1][w - c * i][k - c]);
          }
        }
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 100; j++) {
      if (cnt[j] >= i && dp[100 & 1][j * i][i] == 1) {
        ans = i;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
