#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n;
  cin >> n;
  long long int a[n];
  for (long long int i = 0; i <= n - 1; i++) cin >> a[i];
  long long int i = 0, j = n - 1;
  while (i < n - 1 && a[i] == 0) i++;
  while (j > 0 && a[j] == 0) j--;
  long long int zero = 0;
  while (i < j) {
    if (a[i] == 1 && a[j] == 1) {
      i++;
      j--;
      continue;
    }
    while (i < j && a[i] == 0) {
      i++;
      zero++;
    }
    while (j > i && a[j] == 0) {
      j--;
      zero++;
    }
  }
  if (a[i] == 0) zero++;
  cout << zero << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
