#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e2 + 10;
int dp[2][maxn][maxn * maxn];
int pd[maxn][maxn * maxn];
int a[maxn];
int n;
int sum;
inline void input();
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  input();
}
inline void input() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  dp[0][0][0] = 1;
  pd[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int z = 1; z <= i; z++) {
      for (int j = 0; j <= (int)1e4; j++) {
        if (j < a[i]) {
          dp[1][z][j] = 0;
        } else {
          if (a[i] == a[i - 1]) {
            dp[1][z][j] = dp[0][z - 1][j - a[i]];
          } else {
            dp[1][z][j] = pd[z - 1][j - a[i]];
          }
        }
      }
    }
    for (int z = 1; z <= i; z++) {
      for (int j = 0; j <= (int)1e4; j++) {
        pd[z][j] += dp[1][z][j];
        dp[0][0][0] = 0;
        dp[0][z][j] = dp[1][z][j];
        dp[1][z][j] = 0;
      }
    }
  }
  int ans = 0;
  int pans = 0;
  int res = 1;
  int u = 0;
  for (int i = 1; i <= n; i++) {
    if (i == 1 || a[i] == a[i - 1]) {
      ans += a[i];
      pans++;
    } else {
      u++;
      pans = 1;
      ans = a[i];
    }
    if (pd[pans][ans] == 1) {
      res = max(res, pans);
    }
  }
  if (pd[pans][ans] == 1) {
    res = max(res, pans);
  }
  if (u <= 1) {
    res = n;
  }
  cout << res;
}
