#include <bits/stdc++.h>
inline long long rd() {
  long long _x = 0;
  int _ch = getchar(), _f = 1;
  for (; !isdigit(_ch) && (_ch != '-') && (_ch != EOF); _ch = getchar())
    ;
  if (_ch == '-') {
    _f = 0;
    _ch = getchar();
  }
  for (; isdigit(_ch); _ch = getchar()) _x = _x * 10 + _ch - '0';
  return _f ? _x : -_x;
}
void write(long long _x) {
  if (_x >= 10)
    write(_x / 10), putchar(_x % 10 + '0');
  else
    putchar(_x + '0');
}
inline void wrt(long long _x, char _p) {
  if (_x < 0) putchar('-'), _x = -_x;
  write(_x);
  if (_p) putchar(_p);
}
int n;
long long a[21];
long long sum[1 << 21];
int f[1 << 21];
int main() {
  n = rd();
  memset(f, 0x3f, sizeof f);
  for (int i = 0; i < n; i++) {
    a[i] = rd();
    sum[1 << i] = a[i];
  }
  for (int i = 1; i < (1 << n); i++) {
    sum[i] = sum[i - (i & -i)] + sum[i & (-i)];
  }
  for (int i = 1; i < (1 << n); i++) {
    int p = __builtin_popcount(i);
    f[i] = p;
    if (std::abs(sum[i]) % 2 != (p - 1) % 2) {
      continue;
    }
    if (sum[i] == 0 && p == 1) {
      f[i] = p - 1;
      continue;
    }
    for (int j = (i - 1) & i; j && (2 * j >= i); j = (j - 1) & i) {
      long long x = std::abs(sum[j] - sum[i ^ j]);
      if (x <= p - 1) {
        f[i] = p - 1;
        break;
      }
    }
  }
  for (int i = 1; i < (1 << n); i++) {
    for (int j = i; j && (2 * j >= i); j = (j - 1) & i) {
      f[i] = std::min(f[i], f[j] + f[i ^ j]);
    }
  }
  wrt(f[(1 << n) - 1], '\n');
}
