#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[200];
  vector<int> c(200, 0);
  int counter = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (c[a[i]] == 0) {
      counter++;
    }
    c[a[i]]++;
  }
  if (counter <= 2) {
    cout << n;
  } else {
    vector<vector<int> > dp(10010, vector<int>(200, 0));
    dp[0][0] = 1;
    for (int i = 1; i <= 100; i++) {
      if (c[i] != 0) {
        for (int j = 10000; j > 0; j--) {
          int num = 0;
          for (int ind = 1; ind <= c[i]; ind++) {
            num += i;
            for (int k = 1; k <= 100; k++) {
              if (k - ind >= 0 && j - num >= 0) {
                dp[j][k] += dp[j - num][k - ind];
              }
            }
          }
        }
      }
    }
    int z = 0, k = 0;
    for (int i = 1; i <= 100; i++) {
      int sum = 0;
      for (int j = 1; j <= c[i]; j++) {
        sum += i;
        if (dp[sum][j] == 1 && j > k) {
          k = j;
          z = i;
        }
      }
    }
    cout << k;
  }
  return 0;
}
