#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  char ch;
  bool flag = false;
  for (ch = getchar(); !isdigit(ch); ch = getchar())
    if (ch == '-') flag = true;
  for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar())
    ;
  x = flag ? -x : x;
}
inline void write(int x) {
  static const int maxlen = 100;
  static char s[maxlen];
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (!x) {
    putchar('0');
    return;
  }
  int len = 0;
  for (; x; x /= 10) s[len++] = x % 10 + '0';
  for (int i = len - 1; i >= 0; --i) putchar(s[i]);
}
const int MAXN = 110;
int n;
int a[MAXN];
int f[MAXN][MAXN * MAXN];
int cnt[MAXN];
int main() {
  read(n);
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    read(a[i]);
    cnt[a[i]]++;
    sum += a[i];
  }
  sort(a + 1, a + n + 1);
  f[0][0] = 1;
  for (int i = 1; i <= 100; i++) {
    for (int num = n; num >= 1; num--)
      for (int j = min(cnt[i], num); j >= 1; j--)
        for (int k = j * i; k <= sum; k++)
          f[num][k] = min(2, f[num][k] + f[num - j][k - j * i]);
  }
  int ans = 0;
  if (cnt[a[1]] + cnt[a[n]] == n) ans = n;
  for (int val = 1; val <= 100; val++)
    for (int j = 1; j <= cnt[val]; j++) {
      if (f[j][j * val] == 1) ans = max(ans, j);
    }
  printf("%d\n", ans);
  return 0;
}
