#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n, res = 0;
    cin >> n;
    vector<long long> v(n);
    for (long long i = 0; i < n; i++) {
      cin >> v[i];
      if (v[i] == 0) res++;
    }
    for (long long i = 0; i < n; i++) {
      if (v[i] == 0)
        res--;
      else
        break;
    }
    for (long long i = n - 1; i > -1; i--) {
      if (v[i] == 0)
        res--;
      else
        break;
    }
    cout << res << endl;
  }
  return 0;
}
