#include <bits/stdc++.h>
using namespace std;
void solve(vector<int> &arr) {
  int n = arr.size(), i = 0, j = n - 1, cnt = 0;
  while (i < n) {
    if (arr[i]) {
      break;
    }
    i++;
  }
  while (j >= 0) {
    if (arr[j]) {
      break;
    }
    j--;
  }
  for (int k = i; k <= j; k++) {
    if (arr[k] == 0) {
      cnt++;
    }
  }
  cout << cnt << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> arr(n);
    for (auto &ele : arr) {
      cin >> ele;
    }
    solve(arr);
  }
}
