#include <bits/stdc++.h>
using namespace std;
int n, dp[1070000], cnt[1070000];
long long a[30], val[1070000];
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i], val[1 << i - 1] = a[i];
    if (a[i] == 0) i--, n--;
  }
  const int lim = (1 << n) - 1;
  for (int i = 1; i <= lim; ++i) {
    val[i] = val[i ^ (i & -i)] + val[i & -i];
    cnt[i] = cnt[i ^ (i & -i)] + 1;
    long long sum = val[i];
    dp[i] = cnt[i];
    for (int j = (i - 1) & i; j && 2 * j >= i; j = (j - 1) & i)
      dp[i] = min(dp[i], dp[j] + dp[i ^ j]);
    if (dp[i] == cnt[i])
      for (int j = (i - 1) & i; j && 2 * j >= i; j = (j - 1) & i) {
        long long v = abs(val[j] + val[j] - sum);
        if (v <= cnt[i] - 1 && (!(v - cnt[i] - 1 & 1))) {
          dp[i] = cnt[i] - 1;
          break;
        }
      }
  }
  printf("%d\n", dp[lim]);
  return 0;
}
