#include <bits/stdc++.h>
int main(int argc, const char* argv[]) {
  int x, num;
  scanf("%d", &num);
  for (int i = 0; i < num; i++) {
    scanf("%d", &x);
    int a[x];
    for (int j = 0; j < x; j++) {
      scanf("%d", &a[j]);
    }
    int sum = 0, temp = 0, z = 0;
    for (int i = 0; i < x; i++) {
      if (a[i] == 0) {
        if (z != 0) {
          temp++;
        }
      } else {
        if (z == 0) {
          z = 1;
        } else {
          sum += temp;
          temp = 0;
        }
      }
    }
    printf("%d\n", sum);
  }
  return 0;
}
