#include <bits/stdc++.h>
using namespace std;
int n, color;
int cnt[105];
int dp[105][10005];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    color += !cnt[x];
    cnt[x]++;
  }
  if (color <= 2) return cout << n, 0;
  dp[0][0] = 1;
  for (int i = 1; i <= 100; i++) {
    for (int j = n; j >= 0; j--)
      for (int k = 0; k <= 10000; k++) {
        for (int d = 1; d <= cnt[i]; d++) {
          int &res = dp[j + d][k + d * i];
          if (j + d > n || k + d * i > 10000) break;
          res += dp[j][k];
          if (res >= 2) res = 2;
        }
      }
  }
  int ans = 0;
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= cnt[i]; j++) {
      if (dp[j][i * j] >= 2) break;
      ans = max(ans, j);
    }
  }
  cout << ans;
  return 0;
}
