#include <bits/stdc++.h>
using namespace std;
const int N = 105;
char arr[N], dp[N][N * N], ndp[N][N * N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  int sz = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    arr[x]++;
    if (arr[x] == 1) sz++;
  }
  dp[0][0] = 1;
  for (int i = 1; i < N; i++) {
    for (int x1 = 0; x1 < N; x1++)
      for (int x2 = 0; x2 < N * N; x2++) ndp[x1][x2] = 0;
    for (int f = 0; f <= arr[i]; f++)
      for (int x1 = 0; x1 < N; x1++)
        for (int x2 = 0; x2 < N * N; x2++)
          if (x2 + f * i < N * N && x1 + f < N)
            ndp[x1 + f][x2 + f * i] =
                min(100, ndp[x1 + f][x2 + f * i] + dp[x1][x2]);
    for (int x1 = 0; x1 < N; x1++)
      for (int x2 = 0; x2 < N * N; x2++) dp[x1][x2] = ndp[x1][x2];
  }
  if (sz <= 2) {
    cout << n << '\n';
    return 0;
  }
  int ans = 0;
  for (int i = 1; i < N; i++)
    for (int f = 1; f <= arr[i]; f++)
      if (dp[f][f * i] == 1) ans = max(ans, f);
  cout << ans << '\n';
  return 0;
}
