#include <bits/stdc++.h>
using namespace std;
int n;
int ans, a[110], b[110];
const int mod = 1e9 + 7;
bitset<10100> dp[110];
int main() {
  scanf("%d", &n);
  int ans = 1;
  for (int i = 0, u; i < n; ++i) {
    scanf("%d", &u);
    a[u]++;
    b[i] = u;
  }
  int d = 0;
  for (int i = 1; i <= 100; ++i) {
    d += a[i] > 0;
  }
  if (d <= 2) {
    cout << n << endl;
    return 0;
  }
  for (int i = 1; i <= 100; ++i) {
    for (int j = ans + 1; j <= a[i]; ++j) {
      for (int k = 0; k < j; ++k) {
        dp[k].reset();
      }
      int skip = a[i] - j + 1;
      for (int k = 0; k < n; ++k) {
        if (b[k] == i && skip) {
          skip--;
          continue;
        }
        for (int l = j - 1; l; --l) {
          dp[l] |= dp[l - 1] << b[k];
        }
        dp[0][b[k]] = 1;
      }
      if (dp[j - 1][i * j] == 0) {
        ans = max(ans, j);
      } else {
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
