#include <bits/stdc++.h>
using namespace std;
const int N = 105;
const int M = 100 * 100 + 5;
int a[N];
bitset<M> g[N][2];
void solve2() {
  int n;
  scanf("%d ", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d ", &a[i]);
  }
  sort(a, a + n);
  g[0][0].set(0, true);
  for (int i = 0; i < n;) {
    int j;
    for (j = i; j < n; ++j) {
      if (a[i] != a[j]) break;
    }
    int vv = a[i];
    int num = j - i, t = 0;
    for (int cc = n; cc; --cc) {
      for (int iter = 1; iter <= num && cc - iter >= 0; ++iter) {
        int x = vv * iter;
        g[cc][1] |=
            (g[cc][0] & (g[cc - iter][0] << x)) | (g[cc - iter][1] << x);
        g[cc][0] |= (g[cc - iter][0] << x);
      }
    }
    i = j;
  }
  int num_set = 1;
  for (int i = 0; i + 1 < n; ++i) {
    num_set += (a[i + 1] != a[i]);
  }
  int ret = 0;
  for (int i = 0; i < n;) {
    int j;
    for (j = i; j < n; ++j) {
      if (a[i] != a[j]) break;
    }
    int num = j - i, t = 0;
    for (int iter = 1; iter <= num; ++iter) {
      if (!g[iter][1][iter * a[i]]) {
        t = iter;
      }
    }
    if (t == num && num_set == 2) {
      t = n;
    }
    ret = max(ret, t);
    i = j;
  }
  printf("%d\n", ret);
}
void solve() { solve2(); }
inline bool exists_test0(const std::string& name);
inline bool exists_test1(const std::string& name);
int main() {
  solve();
  return 0;
}
inline bool exists_test0(const std::string& name) {
  ifstream f(name.c_str());
  return f.good();
}
inline bool exists_test1(const std::string& name) {
  if (FILE* file = fopen(name.c_str(), "r")) {
    fclose(file);
    return true;
  } else {
    return false;
  }
}
