#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, cnt = 0, st = -1, end = -1;
    cin >> n;
    vector<int> arr(n);
    for (int i = 0; i < n; ++i) {
      cin >> arr[i];
      if (arr[i]) {
        if (st == -1) st = i;
        end = i;
      }
    }
    for (int i = st; i < end; ++i)
      if (arr[i] == 0) cnt++;
    cout << cnt << "\n";
  }
}
