#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y;
  node(){};
  node(int X, int Y) { x = X, y = Y; }
};
int n, a[105], dp[10005][105], sum[105], ans;
vector<node> G;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sum[a[i]]++;
  }
  for (int i = 1; i <= 100; i++) {
    if (sum[i] != 0) G.push_back(node(i, sum[i]));
  }
  dp[0][0] = 1;
  for (int l = 0; l < G.size(); l++) {
    int xx = G[l].x;
    int yy = G[l].y;
    for (int i = 10000; i >= 1; i--)
      for (int j = 1; j <= n; j++)
        for (int k = 1; k <= j && k <= yy && i - xx * k >= 0; k++) {
          dp[i][j] += dp[i - xx * k][j - k];
          dp[i][j] = min(dp[i][j], 2);
        }
  }
  if (G.size() == 2) {
    printf("%d", n);
    return 0;
  }
  for (int i = 0; i < G.size(); i++) {
    int xx = G[i].x;
    int yy = G[i].y;
    for (int j = 1; j <= yy; j++)
      if (dp[j * xx][j] == 1) ans = max(ans, j);
  }
  printf("%d\n", ans);
}
