#include <bits/stdc++.h>
using namespace std;
bool cmp(int a, int b) { return a > b; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int arr[n];
    int k = -1;
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
      if (arr[i] == 1 and k == -1) k = i;
    }
    int e;
    for (int i = n - 1; i >= 0; i--) {
      if (arr[i] == 1) {
        e = i;
        break;
      }
    }
    int z = 0;
    for (int i = k + 1; i <= e; i++) {
      if (arr[i] == 0) z++;
    }
    cout << z << endl;
  }
  return 0;
}
