#include <bits/stdc++.h>
using namespace std;
void Solve() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    int j = 0, ans = 0, f = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] == 0 && f == 1)
        j++;
      else if (a[i] == 1) {
        f = 1;
        ans += j;
        j = 0;
      }
    }
    cout << ans << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  Solve();
  return 0;
}
