#include <bits/stdc++.h>
using namespace std;
int n, t, mx, a[105], C[105][105], sum, cnt[105], ans = 1, mod = 1e6 + 7;
map<pair<int, int>, int> dp, pre;
int inline read() {
  int res = 0;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    ;
  for (; isdigit(c); res *= 10, res += c ^ 48, c = getchar())
    ;
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  n = read();
  for (int i = 1; i <= n; ++i) {
    a[i] = read();
    sum += a[i];
    mx = max(mx, a[i]);
    ++cnt[a[i]];
  }
  for (int i = 0; i <= n; ++i) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j <= i - 1; ++j) {
      C[i][j] = C[i - 1][j] + C[i - 1][j - 1] % mod;
    }
  }
  pre[make_pair(0, 0)] = 1;
  for (int i = 1; i <= n; ++i) {
    dp = pre;
    for (__typeof(pre.begin()) it = pre.begin(); it != pre.end(); ++it) {
      pair<int, int> cur =
          make_pair(it->first.first + a[i], it->first.second + 1);
      dp[cur] += it->second;
      dp[cur] %= mod;
    }
    pre = dp;
  }
  for (int i = 1; i <= 100; ++i) {
    t += (bool)(cnt[i]);
  }
  if (t == 2 || t == 1) {
    cout << n << '\n';
    return 0;
  }
  for (int i = 1; i <= mx; ++i) {
    for (int j = 2; j <= cnt[i]; ++j) {
      if (dp[make_pair(i * j, j)] == C[cnt[i]][j]) {
        ans = max(ans, j);
      }
    }
  }
  cout << ans << '\n';
}
