#include <bits/stdc++.h>
using namespace std;
int n;
int a[110];
int cnt[110];
int dif[10010][110][2];
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  if (a[0] == a[n - 1]) {
    cout << n << endl;
  } else {
    for (int i = 0; i < n; i++) {
      cnt[a[i]]++;
    }
    int cur = 0;
    dif[0][0][0] = 1;
    for (int i = 1; i <= 100; i++) {
      for (int v = 10000; v >= 0; v--) {
        for (int c = 0; c <= 100; c++) {
          dif[v][c][1 - cur] = dif[v][c][cur];
        }
      }
      for (int j = 1; j <= cnt[i]; j++) {
        for (int v = 10000; v >= 0; v--) {
          for (int c = 0; c <= 100; c++) {
            if (dif[v][c][cur] > 0) {
              dif[v + i * j][c + j][1 - cur] += dif[v][c][cur];
            }
          }
        }
      }
      cur = 1 - cur;
    }
    int ans = 0;
    for (int i = 1; i <= 100; i++) {
      for (int j = 1; j <= cnt[i]; j++) {
        if (dif[i * j][j][cur] == 1) {
          int tans = j;
          if (j == cnt[i]) {
            for (int k = 1; k <= 100; k++) {
              if (k != i) {
                if (cnt[k] == n - j) {
                  tans = n;
                  break;
                }
              }
            }
          }
          ans = max(ans, tans);
        }
      }
    }
    cout << ans << endl;
  }
}
