#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, a, p;
    cin >> n;
    vector<int> v;
    int arr[n];
    int i = 0;
    p = n;
    while (n--) {
      cin >> a;
      arr[i] = a;
      if (a == 1) v.push_back(i);
      i++;
    }
    int start = v[0], end = v[v.size() - 1];
    int c = 0;
    for (int j = start; j <= end; j++) {
      if (arr[j] == 0) c++;
    }
    cout << c;
    cout << endl;
  }
}
