#include <bits/stdc++.h>
using namespace std;
char f[101][10001][101];
int a[105], d[105];
int main() {
  int n;
  cin >> n;
  int sum = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i], sum += a[i];
  }
  sort(a + 1, a + n + 1);
  f[0][0][0] = 1;
  int cnt = 1;
  for (int i = 1; i <= n; ++i) {
    if (i == n || a[i] != a[i + 1]) {
      for (int k = 0; k <= i; ++k) {
        for (int j = 0; j <= sum; ++j) {
          for (int z = 0; z <= min(k, cnt); ++z) {
            if (j >= z * a[i])
              f[i][j][k] = min(f[i][j][k] + f[i - cnt][j - z * a[i]][k - z], 2);
          }
        }
      }
      cnt = 1;
    } else
      cnt++;
  }
  int ret = 1, sl = 0;
  cnt = 1;
  for (int i = 1; i <= n; ++i)
    if (i == n || a[i] != a[i + 1]) {
      for (int j = 1; j <= cnt; ++j)
        if (f[n][j * a[i]][j] == 1) ret = max(ret, j);
      cnt = 1;
      sl++;
    } else
      cnt++;
  if (sl == 2) ret = n;
  cout << ret;
}
