#include <bits/stdc++.h>
using namespace std;
int a[50];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a[i];
    int left = 0, right = n - 1, cnt = accumulate(a, a + n, 0);
    while (!a[left]) ++left;
    while (!a[right]) --right;
    cout << right - left - cnt + 1 << '\n';
  }
}
