#include <bits/stdc++.h>
using namespace std;
void test_case(int cas) {
  int n;
  cin >> n;
  int arr[n];
  int cnt = 0, f = 0, s = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < n; i++) {
    if (arr[i] == 1) {
      f = i;
      break;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (arr[i] == 1) {
      s = i;
      break;
    }
  }
  for (int i = f; i <= s; i++) {
    if (arr[i] == 0) cnt++;
  }
  cout << cnt << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t, cas = 0;
  cin >> t;
  while (t--) test_case(++cas);
  return 0;
}
