#include <bits/stdc++.h>
int call(int x, int y) {
  int i = 0, j = 0;
  return x < y ? x : y;
}
int main() {
  long long int ch[1000000];
  char arr[100000];
  int cp[4] = {0, 0, 0, 0};
  int a, b, c, d, e = 0, g, i = 0, tep = 0, temp = 0, j = 0, k = 0, l = 0,
                  m = 0, n = 0;
  scanf("%d", &a);
  for (i = 1; i <= a; i++) {
    scanf("%d", &b);
    k = 0;
    l = 0;
    for (j = 1; j <= b; j++) {
      scanf("%d", &c);
      k += c;
      if (c == 0) {
        k++;
        l++;
      }
      if (k == 0 && j == b) {
        l++;
      }
    }
    printf("%d\n", l);
  }
  return 0;
}
