#include <bits/stdc++.h>
using namespace std;
void Fast_IO() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
int main() {
  Fast_IO();
  int t;
  cin >> t;
  while (t--) {
    int n, i;
    cin >> n;
    vector<int> a(n);
    int first = -1, last = -1, cur = -1;
    for (i = 0; i < n; i++) {
      cin >> a[i];
      if (first == -1 && a[i] == 1) first = i;
      if (a[i] == 1) cur = i;
    }
    last = cur;
    int ans = 0;
    for (i = first; i <= last; i++) {
      if (a[i] == 0) ans++;
    }
    cout << ans << '\n';
  }
  return 0;
}
