#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    int n, sol = 0, cont = 0;
    cin >> n;
    bool first = false;
    for (int a = 0; a < n; a++) {
      int aux;
      cin >> aux;
      if (aux == 1) {
        first = true;
        sol += cont;
        cont = 0;
      }
      if (aux == 0 and first == true) {
        cont++;
      }
    }
    cout << sol << "\n";
  }
  return 0;
}
