#include <bits/stdc++.h>
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, a[55], i, cnt = 0, k1, k2;
    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    i = 0;
    if (a[n - 1] == 0) {
      while (a[n - 1] != 1) n--;
    }
    while (a[i] != 1) i++;
    for (; i < n; i++) {
      k1 = i;
      while (a[i] != 1) {
        i++;
        if (i == n - 1) {
          if (a[i] == 0) k2 = k1;
        }
      }
      k2 = i;
      cnt += (k2 - k1);
    }
    printf("%d\n", cnt);
  }
}
