#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n, fir = 0, lst = 0, sum = 0;
    cin >> n;
    for (long long i = 1; i <= n; ++i) {
      long long a;
      cin >> a;
      if (a) {
        if (!fir) fir = i;
        lst = i;
        ++sum;
      }
    }
    cout << lst - fir + 1 - sum << endl;
  }
  return 0;
}
