#include <bits/stdc++.h>
using namespace std;
void helper() {
  int n;
  cin >> n;
  vector<int> arr(n, 0);
  for (int i = 0; i < n; i++) cin >> arr[i];
  int s = 0;
  int f = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] == 1) {
      s = i;
      break;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (arr[i] == 1) {
      f = i;
      break;
    }
  }
  int sol = 0;
  for (int i = s; i < f; i++) {
    if (arr[i] == 0) sol++;
  }
  cout << sol << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) helper();
  return 0;
}
