#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const int mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int cnt = 0;
    int a[n + 5];
    int i1 = 60, i2 = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (a[i]) {
        i1 = min(i1, i);
        i2 = max(i2, i);
      }
    }
    int k = 0;
    for (; i1 <= i2; i1++) {
      if (!a[i1]) {
        cnt++;
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
