#include <bits/stdc++.h>
using namespace std;
const int N = 150;
int n, dp[N][N * N], sum, cnt[N], x, u[N][N * N], res;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &x), sum += x, cnt[x]++;
  dp[0][0] = 1;
  for (int i = 1; i <= 100; i++) {
    res += (cnt[i] > 0);
    for (int j = n; j >= 1; j--) {
      for (int cn = 1; cn <= min(j, cnt[i]); cn++) {
        for (int l = i * cn; l <= sum; l++) {
          dp[j][l] += dp[j - cn][l - i * cn];
        }
      }
    }
  }
  if (res == 1 || res == 2) {
    cout << n << endl;
    return 0;
  }
  for (int i = 1; i <= 100; i++)
    for (int cn = 1; cn <= cnt[i]; cn++) u[cn][i * cn] = 1;
  for (int i = n; i >= 1; i--) {
    for (int j = 0; j <= sum; j++) {
      if (dp[i][j] == 1 && u[i][j] == 1) {
        cout << i << endl;
        return 0;
      }
    }
  }
}
