Problem: To defeat Lord Voldemort, Harry needs to destroy all horcruxes first. The last horcrux is an array a of n integers, which also needs to be destroyed. The array is considered destroyed if all its elements are zeroes. To destroy the array, Harry can perform two types of operations:

  1. choose an index i (1 ≤ i ≤ n), an integer x, and subtract x from a_i.
  2. choose two indices i and j (1 ≤ i, j ≤ n; i ≠ j), an integer x, and subtract x from a_i and x + 1 from a_j. 



Note that x does not have to be positive.

<image>

Harry is in a hurry, please help him to find the minimum number of operations required to destroy the array and exterminate Lord Voldemort.

Input

The first line contains a single integer n — the size of the array a (1 ≤ n ≤ 20). 

The following line contains n integers a_1, a_2, …, a_n — array elements (-10^{15} ≤ a_i ≤ 10^{15}).

Output

Output a single integer — the minimum number of operations required to destroy the array a.

Examples

Input


3
1 10 100


Output


3


Input


3
5 3 -2


Output


2


Input


1
0


Output


0

Note

In the first example one can just apply the operation of the first kind three times.

In the second example, one can apply the operation of the second kind two times: first, choose i = 2, j = 1, x = 4, it transforms the array into (0, -1, -2), and then choose i = 3, j = 2, x = -2 to destroy the array.

In the third example, there is nothing to be done, since the array is already destroyed.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = 20, S = 1 << N, hS = 1 << 10;
const int Mod = 1e9 + 9;
template <typename T>
T _abs(T x) {
  return (x < 0) ? (-x) : (x);
}
int n;
long long a[N];
int bit[S];
int f[N + 1][S];
long long sumf[hS], sumg[hS];
vector<long long> F[hS][2], G[hS][2];
void work(int st, int n, vector<long long> (*F)[2], long long* sum) {
  for (int s = 0; s < (1 << n); s++) {
    sum[s] = 0;
    for (int i = 0; i < n; i++) {
      if ((s >> i) & 1) {
        sum[s] += a[st + i];
      }
    }
    for (int t = (s - 1) & s; t; t = (t - 1) & s) {
      long long sum = 0;
      for (int i = 0; i < n; i++) {
        if ((s >> i) & 1) {
          if ((t >> i) & 1) {
            sum += a[st + i];
          } else {
            sum -= a[st + i];
          }
        }
      }
      F[s][sum & 1].push_back(sum);
    }
    sort(F[s][0].begin(), F[s][0].end());
    sort(F[s][1].begin(), F[s][1].end());
  }
}
void fix(int& x) { (x >= Mod) && (x -= Mod); }
void fwt(int* f, int n) {
  int N = (1 << n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < N; j++) {
      if ((j >> i) & 1) {
        fix(f[j] += f[j ^ (1 << i)]);
      }
    }
  }
}
void ifwt(int* f, int n) {
  int N = (1 << n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < N; j++) {
      if ((j >> i) & 1) {
        fix(f[j] += Mod - f[j ^ (1 << i)]);
      }
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%lld", a + i);
  int hn = n >> 1;
  work(0, hn, F, sumf);
  work(hn, n - hn, G, sumg);
  for (int i = 1; i < (1 << n); i++) bit[i] = bit[i >> 1] + (i & 1);
  for (int i = 0; i < n; i++) f[1][1 << i] = 1;
  int S0 = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == 0) {
      S0 |= 1 << i;
    }
  }
  if (bit[S0] == n) {
    puts("0");
    return 0;
  }
  for (int s = 1; s < (1 << n); s++) {
    if (bit[s] == 1) continue;
    int sl = s & ((1 << hn) - 1);
    int sr = (s ^ sl) >> hn;
    int e = bit[s] - 1;
    int par = e & 1;
    bool suc = false;
    for (int parl = 0; parl < 2 && !suc; parl++) {
      int parh = par ^ parl;
      auto pl = G[sr][parh].rbegin();
      auto pr = G[sr][parh].rbegin();
      auto _p = G[sr][parh].rend();
      for (auto x : F[sl][parl]) {
        while (pl != _p && *pl >= -x - e) pl++;
        while (pr != _p && *pr > -x + e) pr++;
        if (pl != pr) {
          suc = true;
          break;
        }
      }
      if (!suc) {
        if ((sumf[sl] & 1) == parl) {
          suc = suc || (lower_bound(G[sr][parh].begin(), G[sr][parh].end(),
                                    -sumf[sl] - e) !=
                        lower_bound(G[sr][parh].begin(), G[sr][parh].end(),
                                    -sumf[sl] + e + 1));
        }
        if ((sumg[sr] & 1) == parh) {
          suc = suc || (lower_bound(F[sl][parl].begin(), F[sl][parl].end(),
                                    -sumg[sr] - e) !=
                        lower_bound(F[sl][parl].begin(), F[sl][parl].end(),
                                    -sumg[sr] + e + 1));
        }
        if ((sumf[sl] & 1) == parl && (sumg[sr] & 1) == parh && sl && sr) {
          suc = suc || _abs(sumf[sl] - sumg[sr]) <= e;
        }
      }
    }
    f[e][s] = suc;
  }
  for (int i = 1; i <= n; i++) {
    fwt(f[i], n);
    for (int j = 1; j < i; j++) {
      for (int s = 0; s < (1 << n); s++) {
        f[i][s] = (f[i][s] + 1ll * f[j][s] * f[i - j][s]) % Mod;
      }
    }
    ifwt(f[i], n);
    for (int s = 0; s < (1 << n); s++) {
      if (f[i][s] && bit[s | S0] == n) {
        printf("%d\n", i);
        return 0;
      }
    }
    fwt(f[i], n);
  }
  assert(false);
  return 0;
}