#include <bits/stdc++.h>
using namespace std;
long long a[25];
int n, ac[1 << 20];
long long w1[1 << 20], w2[1 << 20], now1[1 << 20], now2[1 << 20], now3[1 << 20],
    sk[25];
void solve(long long *w, int l, int r) {
  int sz = 1;
  now1[sz] = 0;
  for (int i = l; i <= r; ++i) {
    for (int j = 1; j <= sz; ++j)
      now2[j] = now1[j] + sk[i], now3[j] = now1[j] - sk[i];
    int tot = 0, l = 1, r = 1;
    while (l <= sz && r <= sz) {
      if (now2[l] <= now3[r])
        now1[++tot] = now2[l++];
      else
        now1[++tot] = now3[r++];
    }
    while (l <= sz) now1[++tot] = now2[l++];
    while (r <= sz) now1[++tot] = now3[r++];
    sz = tot;
  }
  for (int i = 1; i <= sz; ++i) w[i] = now1[i];
}
bool check(int x) {
  int tot = 0;
  long long w = 0;
  for (int i = 0; i < n; ++i)
    if ((1 << i) & x) sk[++tot] = a[i + 1], w += a[i + 1];
  if ((w - (tot - 1)) & 1) return 0;
  solve(w1, 1, tot / 2);
  solve(w2, tot / 2 + 1, tot);
  int n = 1 << (tot / 2), m = 1 << (tot - tot / 2), r = 1,
      fk = 1 + (abs(w) < tot) * 2;
  for (int i = n; i >= 1; --i) {
    while (r <= m && w1[i] + w2[r] < -(tot - 1)) ++r;
    for (int j = r; j <= m && fk && w1[i] + w2[j] < tot; ++j) fk--;
  }
  return !fk;
}
int main() {
  scanf("%d", &n);
  int cs = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &a[i]);
    if (a[i]) a[++cs] = a[i];
  }
  n = cs;
  int len = 1 << n;
  for (int i = 1; i < len; ++i)
    if (!ac[i] && check(i)) {
      ac[i] = 1;
      int t = (len - 1) ^ i;
      for (int j = t; j; j = (j - 1) & t)
        ac[i | j] = max(ac[i | j], ac[i] + ac[j]);
    }
  printf("%d", n - ac[len - 1]);
}
