#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
void solve() {
  int n;
  cin >> n;
  int count = 0;
  int res = 0;
  bool b = false;
  int c;
  for (int i = 0; i < n; i++) {
    cin >> c;
    if (c == 1) {
      b = true;
      res += count;
      count = 0;
    }
    if (b && c == 0) {
      count++;
    }
  }
  cout << res << endl;
}
