#include <bits/stdc++.h>
using namespace std;
int main() {
  int arr[200];
  int n;
  cin >> n;
  while (n > 0) {
    int a;
    cin >> a;
    int aw, ak = 0;
    int cek = -1;
    int jum = 0;
    for (int i = 1; i <= a; i++) {
      cin >> arr[i];
      if ((arr[i] == 1) && (cek == -1)) {
        aw = i;
        ak = i;
        jum = jum + 1;
        cek = 1;
      } else if (arr[i] == 1) {
        ak = i;
        jum = jum + 1;
      }
    }
    int sum = ak - aw + 1 - jum;
    cout << sum << endl;
    n--;
  }
  return 0;
}
