#include <bits/stdc++.h>
using namespace std;
const int inv = 1000000000;
const int minv = -inv;
const int max_n = 100 + 5;
const int max_sum = 10000 + 5;
int n;
int a[max_n];
int m;
int b[max_n];
vector<int> c;
int dp[max_n + 1][max_sum + 1] = {0};
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  sort(a, a + n);
  c.push_back(0);
  for (int i = 1; i < n; ++i)
    if (a[i - 1] != a[i]) c.push_back(i);
  c.push_back(n);
  if ((int)c.size() <= 3) {
    printf("%d\n", n);
    return 0;
  }
  int res = 1;
  for (int p = 0; p < (int)c.size() - 1; ++p) {
    int l = c[p], r = c[p + 1];
    if (r - l == 1) continue;
    m = 0;
    for (int i = 0; i < n; ++i)
      if (i < l or i >= r) b[m++] = a[i];
    dp[0][0] = true;
    for (int i = 0; i < m; ++i) {
      for (int j = min(i + 1, r - l); j > 0; --j)
        for (int k = b[i]; k < j * a[n - 1] + 1; ++k)
          dp[j][k] = (dp[j][k] or dp[j - 1][k - b[i]]);
    }
    int cres = 1;
    for (int j = 2; j < r - l + 1; ++j)
      if (dp[j][a[l] * j])
        break;
      else
        cres = j;
    res = max(res, cres);
    for (int j = 1; j < r - l + 1; ++j)
      for (int k = 0; k < j * a[n - 1] + 1; ++k) dp[j][k] = false;
  }
  printf("%d\n", res);
  return 0;
}
