#include <bits/stdc++.h>
using namespace std;
int binpow(int x, int y) {
  int ans = 1;
  while (y) {
    if (y & 1) ans = (ans * x) % 998244353;
    x = (x * x) % 998244353;
    y >>= 1;
  }
  return ans;
}
int dp[10005][105], sum[10005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, i, j;
  cin >> n;
  int a[n + 5];
  int s = 0, k;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    s += a[i];
  }
  bool dp[s + 1][n + 1], dp_all_same[s + 1][n + 1];
  for (i = 0; i <= s; i++) {
    for (j = 0; j <= n; j++) {
      dp[i][j] = false;
      dp_all_same[i][j] = false;
    }
  }
  dp[0][0] = true;
  dp_all_same[0][0] = true;
  for (i = 0; i < n; i++) {
    for (j = s; j >= a[i]; j--) {
      for (k = n; k >= 1; k--) {
        if (dp_all_same[j - a[i]][k - 1]) {
          if (k != 1) {
            if (a[i] != ((j - a[i]) / (k - 1))) {
              dp[j][k] = true;
              continue;
            }
          }
          dp_all_same[j][k] = true;
        } else if (dp[j - a[i]][k - 1]) {
          dp[j][k] = true;
        }
      }
    }
  }
  int ans = -1;
  for (j = n; j >= 0; j--) {
    for (i = s; i >= 1; i--) {
      if (dp_all_same[i][j] && !dp[i][j]) {
        ans = j;
        if (dp_all_same[s - i][n - j] && !dp[s - i][n - j]) ans += n - j;
        break;
      }
    }
    if (ans != -1) break;
  }
  cout << ans;
}
