#include <bits/stdc++.h>
using namespace std;
inline int gi() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 3) + (x << 1) + ch - 48;
    ch = getchar();
  }
  return x * f;
}
template <typename T>
inline bool Max(T &a, T b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T>
inline bool Min(T &a, T b) {
  return b < a ? a = b, 1 : 0;
}
const int N = 104;
int n, cnt, ans;
int a[N], f[N][N * N], g[N][N * N];
int main() {
  n = gi();
  for (int i = 1; i <= n; ++i) a[i] = gi();
  sort(a + 1, a + 1 + n);
  f[0][0] = 1;
  for (int i = 1, j = 1; i <= n; i = j + 1, j = i) {
    while (j + 1 <= n && a[j + 1] == a[j]) ++j;
    for (int k = 1; k <= j - i + 1; ++k)
      for (int dep = n; dep; --dep)
        for (int v = 10000; v >= a[i]; --v) {
          g[dep][v] |= ((f[dep - 1][v - a[i]] && f[dep - 1][v - a[i]] != a[i] &&
                         v - a[i] != 0) ||
                        g[dep - 1][v - a[i]]);
          if (f[dep - 1][v - a[i]]) f[dep][v] = a[i];
        }
  }
  for (int i = 1, j = 1; i <= n; i = j + 1, j = i) {
    ++cnt;
    while (j + 1 <= n && a[j + 1] == a[j]) ++j;
    for (int k = 1; k <= j - i + 1; ++k) {
      if (g[k][k * a[i]]) continue;
      Max(ans, k);
    }
  }
  if (ans == n - 1) ++ans;
  if (cnt == 2)
    printf("%d\n", n);
  else
    printf("%d\n", ans);
  return 0;
}
