#include <bits/stdc++.h>
using namespace std;
long long a[100005];
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    for (long long i = 1; i <= n; i++) cin >> a[i];
    long long ma = -1;
    long long mi = n + 1;
    long long c1 = 0;
    for (long long i = 1; i <= n; i++) {
      if (a[i] == 1) {
        ma = max(ma, i);
        mi = min(mi, i);
      }
    }
    long long c0 = 0;
    for (long long i = mi; i <= ma; i++) c0 += (a[i] == 0);
    cout << c0 << endl;
  }
}
