#include <bits/stdc++.h>
using namespace std;
int n, a[111];
int f[111][111 * 111];
int c[111];
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    c[a[i]]++;
  }
  int ans = 0;
  for (int w = 1; w <= 100; ++w) {
    if (c[w] <= ans) continue;
    memset(f, 0, sizeof(f));
    f[0][0] = 1;
    for (int i = 0; i < n; ++i) {
      if (a[i] == w) continue;
      for (int k = 100; k >= 0; --k) {
        for (int w = 100 * k; w >= 0; --w) {
          f[k + 1][w + a[i]] |= f[k][w];
        }
      }
    }
    for (int k = 1; k <= 100; ++k) {
      if (f[k][w * k] == 0 && c[w] >= k) {
        bool ok = 1;
        for (int k2 = 1; k2 < k; ++k2) {
          if (f[k2][w * k2] == 1) {
            ok = 0;
            break;
          }
        }
        if (ok) {
          ans = max(ans, k);
          if (c[w] == k) {
            for (int w2 = 1; w2 <= 100; ++w2) {
              if (w2 != w && c[w2] == n - k) {
                ans = n;
              }
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
}
