#include <bits/stdc++.h>
using namespace std;
int t, n, num, ans;
int a[55];
int main() {
  scanf("%d", &t);
  while (t--) {
    ans = 0;
    num = 0;
    scanf("%d", &n);
    int p;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &p);
      if (p == 1) {
        a[++num] = i;
      }
    }
    for (int i = 2; i <= num; i++) {
      ans += a[i] - a[i - 1] - 1;
    }
    printf("%d\n", ans);
  }
  return 0;
}
