#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int l = 1; l <= n; l++) {
    int a[10000];
    int k;
    cin >> k;
    int dem = 0;
    for (int i = 1; i <= k; i++) cin >> a[i];
    for (int i = 1; i <= k; i++) {
      for (int j = i + 1; j <= k; j++) {
        if (a[i] == 1 && a[j] == 1) {
          dem += j - i - 1;
          i = j;
        }
      }
    }
    cout << dem << endl;
  }
}
