#include <bits/stdc++.h>
using namespace std;
const int MAXN = 105;
const int MOD = 1e9 + 7;
int n;
int arr[MAXN];
char dp[2][MAXN][MAXN * MAXN];
int cnt[MAXN];
int main() {
  cin >> n;
  int sum = 0;
  set<int> unik;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    sum += arr[i];
    cnt[arr[i]]++;
    unik.insert(arr[i]);
  }
  if (unik.size() <= 2) {
    printf("%d\n", n);
    return 0;
  }
  int old = 1, cur = 0;
  dp[0][0][0] = 1;
  for (auto x : unik) {
    swap(cur, old);
    for (int sm = 0; sm <= sum; sm++) {
      for (int use = 0; use <= n; use++) {
        char &ret = dp[cur][use][sm];
        ret = 0;
        for (int cuse = 0; cuse <= cnt[x] && cuse <= use && cuse * x <= sm;
             cuse++) {
          ret += dp[old][use - cuse][sm - x * cuse];
          if (ret > 2) ret = 2;
        }
      }
    }
  }
  int ans = 1;
  for (int i = 0; i < n; i++) {
    for (int use = 1; use <= cnt[arr[i]]; use++) {
      if (dp[cur][use][arr[i] * use] == 1) {
        ans = max(ans, use);
      }
    }
  }
  printf("%d\n", ans);
}
