#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 2e18;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long a[n + 5];
    for (long long i = 0; i < n; ++i) {
      cin >> a[i];
    }
    long long fi = -1;
    long long si = -1;
    for (long long i = 0; i < n; i++) {
      if (a[i]) {
        fi = i;
        break;
      }
    }
    for (long long i = n - 1; i >= 0; i--) {
      if (a[i]) {
        si = i;
        break;
      }
    }
    if (fi == -1) {
      cout << 0 << '\n';
    } else {
      long long cnt = 0;
      for (long long i = fi; i <= si; i++) {
        if (!a[i]) cnt++;
      }
      cout << cnt << '\n';
    }
  }
  return 0;
}
