#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n, f = 0, c = 0;
    cin >> n;
    long long a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) {
      if (a[i] == 1)
        f = 1;
      else if (f == 1)
        c++;
    }
    for (int i = n - 1; i >= 0; i--) {
      if (a[i] == 0)
        c--;
      else
        break;
    }
    cout << c << endl;
  }
}
