#include <bits/stdc++.h>
using namespace std;
int n, t;
bool arr[52];
int ml, mr;
int cont;
int i;
int main() {
  cin >> t;
  while (t > 0) {
    t--;
    cin >> n;
    for (i = 0; i < n; i++) {
      cin >> arr[i];
    }
    ml = 0;
    mr = n - 1;
    while (arr[mr] == 0) {
      mr--;
    }
    while (arr[ml] == 0) {
      ml++;
    }
    cont = 0;
    for (ml; ml < mr; ml++) {
      if (arr[ml] == 0) {
        cont++;
      }
    }
    cout << cont << "\n";
  }
  return 0;
}
