#include <bits/stdc++.h>
using namespace std;
int n, m, S, tot;
int a[105], t[105];
int f[2][105][105 * 105];
int c[105][105], ans;
signed main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    t[a[i]]++;
    S += a[i];
    m = max(m, a[i]);
  }
  for (int i = 1; i <= m; i++) {
    tot += (bool)(t[i]);
  }
  if (tot == 1 || tot == 2) {
    cout << n << "\n";
    return 0;
  }
  memset(f[0], 0xc0, sizeof(f[0]));
  f[0][0][0] = 0;
  memcpy(f[1], f[0], sizeof(f[0]));
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= t[i]; j++) {
      for (int k = j; k <= n; k++) {
        for (int l = i * j; l <= S; l++)
          f[0][k][l] = max(f[0][k][l], f[1][k - j][l - i * j] + 1);
      }
    }
    memcpy(f[1], f[0], sizeof(f[0]));
  }
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= t[i]; j++) {
      if (f[0][j][i * j] == 1) ans = max(ans, j);
    }
  }
  cout << ans;
  return 0;
}
