#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("-O3")
const int MAXN = 21;
long long sum[1 << MAXN];
int best[1 << MAXN];
int cnt[1 << MAXN];
long long tab[MAXN];
int pot2[MAXN];
int n;
void pre() {
  for (int i = 0; i < (MAXN); ++i) pot2[i] = (1 << i);
  for (int S = 0; S < pot2[n]; S++) {
    cnt[S] = __builtin_popcount(S);
    for (int i = 0; i < (MAXN); ++i)
      if (S & pot2[i]) {
        sum[S] += tab[i];
        best[S] = (tab[i] == 0) ? 0 : 1;
      }
  }
}
void count() {
  for (int S = 0; S < pot2[n]; S++) {
    if (cnt[S] < 2) continue;
    best[S] = cnt[S];
    int ile = cnt[S];
    int ilep2 = ile / 2;
    bool znalazlem = ((sum[S] + cnt[S] - 1) % 2 != 0);
    for (int Sp = (S - 1) & S; Sp; Sp = (Sp - 1) & S) {
      if (best[Sp] + best[S ^ Sp] < best[S]) {
        znalazlem = true;
        best[S] = best[Sp] + best[S ^ Sp];
      }
      if (!znalazlem) {
        if (sum[Sp] - sum[S ^ Sp] < ile && sum[Sp] - sum[S ^ Sp] > -ile) {
          znalazlem = true;
          best[S] = cnt[S] - 1;
        }
      }
    }
  }
  cout << best[pot2[n] - 1] << "\n";
}
int main() {
  ios_base::sync_with_stdio(0), cout.setf(ios::fixed), cout.precision(10);
  cin >> n;
  for (int i = 0; i < (n); ++i) cin >> tab[i];
  pre();
  count();
}
