#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long a[n];
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
    }
    long long f0, l0, cntZero = 0;
    for (long long i = 0; i < n; i++) {
      if (a[i] == 1) {
        f0 = i;
        break;
      }
    }
    for (long long i = n - 1; i >= 0; i--) {
      if (a[i] == 1) {
        l0 = i;
        break;
      }
    }
    for (long long x = f0; x <= l0; x++) {
      if (a[x] == 0) cntZero++;
    }
    cout << cntZero << "\n";
  }
  return 0;
}
