#include <bits/stdc++.h>
using namespace std;
int n, cnt[105];
int dp[2][105][10005];
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;
    cnt[x]++;
  }
  int t = 0;
  for (int i = 1; i <= 100; ++i)
    if (cnt[i]) ++t;
  if (t == 2) {
    cout << n << endl;
    return 0;
  }
  int pre = 1, cur = 0;
  dp[0][0][0] = 1;
  int sum = 0, s2 = 0;
  for (int i = 1; i <= 100; ++i) {
    pre ^= 1, cur ^= 1;
    memcpy(dp[cur], dp[pre], sizeof dp[pre]);
    sum += cnt[i];
    s2 += cnt[i] * i;
    for (int k = 0; k <= s2; ++k) {
      for (int l = 0; l <= sum; ++l) {
        if (dp[cur][l][k] == 2) continue;
        for (int j = 1, t = min(k / i, min(l, cnt[i])); j <= t; ++j) {
          dp[cur][l][k] += dp[pre][l - j][k - j * i];
        }
        dp[cur][l][k] = min(dp[cur][l][k], 2);
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= 100; ++i) {
    for (int j = 1; j <= cnt[i]; ++j) {
      if (dp[cur][j][j * i] == 1) ans = max(ans, j);
    }
  }
  cout << ans << endl;
  return 0;
}
