#include <bits/stdc++.h>
using namespace std;
int main() {
  int p;
  cin >> p;
  while (p--) {
    int y = 0, n, z = 0, x = 0;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (a[i] == 0) z++;
    }
    for (int i = 0; i < n; i++) {
      if (a[i] == 1)
        break;
      else
        x++;
    }
    for (int i = n - 1; i >= 0; i--) {
      if (a[i] == 1)
        break;
      else
        x++;
    }
    cout << z - x - y << "\n";
  }
}
