#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n, x, w[N], dp[N][N * N];
int main() {
  scanf("%d", &n);
  int m = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    w[x]++;
    m = max(m, x);
  }
  int mx = 0;
  dp[0][0] = 1;
  for (int i = 1; i <= m; i++) {
    int amx = mx;
    for (int a = n; a >= 0; a--) {
      for (int b = mx; b >= 0; b--) {
        if (dp[a][b] == 0) continue;
        for (int j = 1; j <= w[i]; j++) {
          int c = a + j, d = b + j * i;
          amx = max(amx, d);
          dp[c][d] += dp[a][b];
          if (dp[c][d] > 2) dp[c][d] = 2;
        }
      }
    }
    mx = amx;
  }
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= w[i]; j++) {
      if (dp[j][i * j] == 1) {
        ans = max(ans, j);
      }
    }
  }
  int c = 0;
  for (int i = 1; i <= m; i++) {
    if (w[i] > 0) c++;
  }
  if (c == 2) ans = n;
  printf("%d\n", ans);
}
