#include <bits/stdc++.h>
const int N = 1e5 + 1, INF = 1e9;
int dp[101][10003];
int main() {
  int n;
  dp[0][0] = 1;
  scanf("%d", &n);
  std::vector<int> c(101, 0);
  int r = 0;
  for (int k = 0; k < n; k++) {
    int x;
    scanf("%d", &x);
    std::vector<std::pair<int, int> > l = {};
    if (!c[x]) r++;
    c[x]++;
    for (int i = 0; i + x < 10003; i++) {
      for (int j = 0; j <= k; j++) {
        if (dp[j][i]) {
          if (c[x] * x <= i + x) l.push_back({j + 1, i + x});
        }
      }
    }
    for (auto i : l) {
      dp[i.first][i.second] += dp[i.first - 1][i.second - x];
    }
  }
  if (r == 2) return !printf("%d", n);
  int ans = 1;
  for (int i = 1; i <= 100; i++) {
    for (int j = ans + 1; j <= c[i]; j++) {
      if (dp[j][j * i] == 1) ans = j;
    }
  }
  printf("%d", ans);
}
