#include <bits/stdc++.h>
using namespace std;
const int N = 21, M = (1 << 21);
int n, dp[M];
long long w[N], opt[M];
bool ft[M];
int main() {
  cin >> n;
  int sum = 19260817;
  int q = 0;
  for (int i = 1; i <= n; i++) {
    cin >> w[++q];
    if (!w[q]) q--;
  }
  for (int i = 1; i < (1 << n); i++)
    for (int x = 1; x <= n; x++)
      if (i & (1 << (x - 1))) opt[i] = opt[i - (1 << (x - 1))] + w[x];
  for (int i = 1; i < (1 << n); i++) {
    int t = __builtin_popcount(i);
    if (abs(opt[i]) % 2 == abs(t) % 2) continue;
    for (int j = i & (i - 1); j > 0; j = i & (j - 1))
      if (opt[j] - opt[i ^ j] >= 0 && opt[j] - opt[i ^ j] < t) {
        ft[i] = 1;
        break;
      }
  }
  n = q;
  if (!n) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 1; i < (1 << n); i++) dp[i] = 0;
  for (int i = 1; i < (1 << n); i++) {
    if (ft[i]) dp[i] = 1;
    for (int j = i & (i - 1); j > 0; j = i & (j - 1))
      if (ft[j]) {
        dp[i] = max(dp[i], dp[i ^ j] + 1);
      }
  }
  int of = (1 << n) - 1;
  for (int i = 0; i < (1 << n); i++) sum = min(sum, n - dp[i]);
  cout << sum << endl;
}
