#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> s(n);
    int fst = n, lst = 0;
    for (int i = 0; i < n; ++i) {
      cin >> s[i];
      if (s[i] == 1) {
        fst = min(fst, i);
        lst = max(lst, i);
      }
    }
    cout << count_if(s.begin() + fst, s.begin() + lst, [](int i) {
      return i == 0;
    }) << "\n";
  }
  return 0;
}
