#include <bits/stdc++.h>
using namespace std;
int n;
int a[105], b[105];
int dp[2][10005][105];
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int(i) = (1); (i) <= (n); (i)++) cin >> a[i], b[a[i]]++;
  int kind = 0;
  for (int(i) = (1); (i) <= (100); (i)++)
    if (b[i]) kind++;
  for (int(i) = (0); (i) <= (1); (i)++) {
    for (int(j) = (0); (j) <= (10000); (j)++) {
      for (int(k) = (0); (k) <= (n); (k)++) {
        dp[i][j][k] = 0;
      }
    }
  }
  dp[0][0][0] = 1;
  for (int(i) = (0); (i) <= (99); (i)++) {
    for (int(j) = (0); (j) <= (10000); (j)++) {
      for (int(k) = (0); (k) <= (n); (k)++) {
        dp[(i + 1) & 1][j][k] = 0;
      }
    }
    for (int(j) = (0); (j) <= (10000); (j)++) {
      for (int(k) = (0); (k) <= (n); (k)++) {
        for (int(l) = (0); (l) <= (b[i + 1]); (l)++) {
          if (j + l * (i + 1) > 10000 || k + l > n) break;
          dp[(i + 1) & 1][j + l * (i + 1)][k + l] += dp[i & 1][j][k];
          (dp[(i + 1) & 1][j + l * (i + 1)][k + l]) =
              min((dp[(i + 1) & 1][j + l * (i + 1)][k + l]), (2));
        }
      }
    }
  }
  int ans = 0;
  for (int(i) = (1); (i) <= (100); (i)++) {
    for (int(j) = (1); (j) <= (b[i]); (j)++) {
      if (dp[0][j * i][j] == 1) {
        (ans) = max((ans), (j));
        if (kind == 2 && j == b[i]) ans = n;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
