#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  return (a.first < b.first || (a.first == b.first && a.second < b.second));
}
int main() {
  int test;
  vector<int> occho;
  cin >> test;
  for (int i = 1; i <= test; i++) {
    int n;
    cin >> n;
    for (int j = 1; j <= n; j++) {
      int x;
      cin >> x;
      occho.push_back(x);
    }
    while (occho.back() == 0) {
      occho.pop_back();
    }
    reverse(occho.begin(), occho.end());
    while (occho.back() == 0) {
      occho.pop_back();
    }
    cout << count(occho.begin(), occho.end(), 0) << endl;
    occho.clear();
  }
}
