#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
using namespace std;
int a, b, c, d, n, m, k;
int mas[102];
int dp[2][102][10002];
inline void upd(int& a, int b) {
  a += b;
  if (a >= 3) a = 3;
}
int main() {
  scanf("%d", &n);
  map<int, int> df;
  int s = 0;
  for (int _n((n)-1), i(0); i <= _n; i++) {
    scanf("%d", &mas[i]);
    ++df[mas[i]];
    s += mas[i];
  }
  sort(mas, mas + n);
  if (df.size() <= 2) {
    printf("%d\n", n);
    exit(0);
  }
  int now = 1, nx = 0;
  dp[nx][0][0] = 1;
  for (const auto& it : df) {
    const int w = it.first;
    const int cnt = it.second;
    swap(now, nx);
    memset((dp[nx]), 0, sizeof(dp[nx]));
    for (int _n((101) - 1), j(0); j <= _n; j++) {
      for (int _n((10001) - 1), z(0); z <= _n; z++) {
        if (!dp[now][j][z]) continue;
        int cd = dp[now][j][z];
        for (int _n((cnt + 1) - 1), l(0); l <= _n; l++) {
          upd(dp[nx][j + l][z + w * l], cd);
        }
      }
    }
  }
  int ans = 1;
  for (const auto& it : df) {
    for (int _n(it.second), j(ans + 1); j <= _n; j++) {
      int cw = j * it.first;
      if (dp[nx][j][cw] == 1) {
        ans = max(ans, j);
      }
    }
  }
  printf("%d\n", ans);
}
