#include <bits/stdc++.h>
using namespace std;
bool a[100];
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    int l = 0, r, ans = 0;
    while (!a[l]) l++;
    r = l + 1;
    while (l < n && r < n) {
      while (r < n && !a[r]) r++;
      if (r < n) ans += r - l - 1;
      l = r;
      r++;
    }
    cout << ans << '\n';
  }
  return 0;
}
