#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
int mitm(vector<ll> vals, ll a, ll b) {
  if (vals.size() & 1) vals.push_back(0);
  int n = (int)vals.size() / 2;
  int m = 1 << n;
  vector<ll> le(m), ri(m);
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i & (1 << j)) {
        le[i] += vals[j];
        ri[i] += vals[j + n];
      }
    }
  }
  sort(le.begin(), le.end());
  sort(ri.begin(), ri.end());
  int x = m - 1;
  int y = m - 1;
  int res = 0;
  for (int i = 0; i < m; ++i) {
    while (x >= 0 && le[i] + ri[x] > b) --x;
    while (y >= 0 && le[i] + ri[y] >= a) --y;
    res += x - y;
  }
  return res;
}
const int N = 20;
ll vals[N];
vector<bool> works[N + 1];
int dp[1048576];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int m = 1 << n;
  for (int i = 0; i < n; ++i) cin >> vals[i];
  for (int i = 1; i <= n; ++i) works[i].resize(m, 0);
  works[0].resize(m, 1);
  for (int i = 1; i < m; ++i) {
    ll sum = 0;
    vector<ll> act;
    for (int j = 0; j < n; ++j) {
      if (i & (1 << j)) {
        act.push_back(2 * vals[j]);
        sum += vals[j];
      }
    }
    int cou = __builtin_popcount(i);
    dp[i] = cou;
    if ((sum + cou) & 1) {
      int tot = mitm(act, sum - (cou - 1), sum + (cou - 1));
      if (abs(sum) <= cou - 1) tot -= 2;
      if (tot) --dp[i];
    }
  }
  for (int i = 1; i < m; ++i) {
    for (int j = i; j; j = (j - 1) & i) {
      dp[i] = min(dp[i], dp[j] + dp[i ^ j]);
    }
  }
  printf("%d\n", dp[m - 1]);
}
