#include <bits/stdc++.h>
int n;
std::map<int, int> map;
std::vector<int> vec;
std::vector<std::pair<int, int> > A;
std::bitset<100> dp[10005];
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  std::cin >> n;
  for (int i = 0; i < (n); ++i) {
    int a;
    std::cin >> a;
    map[a]++;
    vec.push_back(a);
  }
  for (auto &pr : map) A.push_back(pr);
  if (((int)(A).size()) <= 2) {
    std::cout << n << "\n";
    return 0;
  }
  int best = 1;
  for (int i = 0; i < (((int)(A).size())); ++i) {
    auto pr = A[i];
    if (pr.second == 1) continue;
    for (int j = 0; j < (10005); ++j) dp[j].reset();
    int sum = 0;
    for (auto &val : vec)
      if (val != pr.first) {
        sum += val;
        for (int j = 10000; j - val >= 0; --j) dp[j] |= dp[j - val] << 1;
        dp[val][0] = true;
      }
    for (int j = (2); j < (pr.second + 1); ++j) {
      for (int k = 10000; k - pr.first >= 0; --k)
        dp[k] |= dp[k - pr.first] << 1;
      dp[pr.first][0] = true;
      if (!dp[j * pr.first][j - 1]) {
        best = std::max(best, j);
      }
    }
  }
  std::cout << best << "\n";
  return 0;
}
