#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int *arr = new int[n];
    for (int i = 0; i < n; i++) cin >> arr[i];
    int j, k;
    for (int i = 0; i < n; i++) {
      if (arr[i] == 1) {
        j = i;
        break;
      }
    }
    for (int i = n - 1; i >= 0; i--) {
      if (arr[i] == 1) {
        k = i;
        break;
      }
    }
    int ans = 0;
    for (int i = j; i <= k; i++) {
      if (arr[i] == 0) ans++;
    }
    cout << ans << endl;
  }
  return 0;
}
