#include <bits/stdc++.h>
using namespace std;
const int N = 1e2 + 10;
int n, a[N], s[N];
int g[N][N * N];
int main() {
  scanf("%d", &n);
  int m = 0;
  for (int i = (1); i <= (n); ++i) scanf("%d", &a[i]), s[a[i]]++, m += a[i];
  bool flag = false;
  for (int i = (1); i <= (100); ++i) {
    int left = m - i * s[i];
    if (left == i * s[i]) continue;
    for (int j = (i + 1); j <= (100); ++j)
      if (j != i && left % j == 0 && left / j <= s[j]) {
        flag = true;
        break;
      }
    if (flag) break;
  }
  if (flag) {
    printf("%d\n", n);
    return 0;
  }
  g[0][0] = 1;
  for (int i = (1); i <= (100); ++i)
    if (s[i])
      for (int j = (m); j >= (1); --j)
        for (int t = (1); t <= (n); ++t)
          for (int k = (1); k <= (s[i]); ++k) {
            if (k * i > j) break;
            if (k > t) break;
            g[t][j] += g[t - k][j - k * i];
          }
  int ans = 0;
  for (int i = (1); i <= (100); ++i)
    for (int j = (1); j <= (s[i]); ++j)
      if (g[j][j * i] == 1) ans = max(ans, j);
  printf("%d\n", ans);
  return 0;
}
