#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using LD = long double;
using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pld = pair<LD, LD>;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> nrs(n);
    for (int &nr : nrs) {
      cin >> nr;
    }
    int i;
    for (i = 0; i < n && nrs[i] == 0; ++i)
      ;
    int res = 0, cur_gap_size = 0;
    while (i < n) {
      for (++i; i < n && nrs[i] == 0; ++i, ++cur_gap_size)
        ;
      if (i != n) {
        res += cur_gap_size;
      }
      cur_gap_size = 0;
    }
    cout << res << "\n";
  }
}
