#include <bits/stdc++.h>
using namespace std;
int a[55], s[55];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    int l = 2000000000, r = 0;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      s[i] = s[i - 1];
      if (a[i] == 1) {
        l = min(i, l);
        r = max(r, i);
      } else
        s[i]++;
    }
    cout << s[r] - s[l] << "\n";
  }
}
