#include <bits/stdc++.h>
using namespace std;
int a[1000];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int x, z = 0, y = 0, num = 0;
    cin >> x;
    for (int i = 1; i <= x; i++) {
      cin >> a[i];
      if (a[i] == 1 && z == 0) z = i;
      if (a[i] == 1) y = i;
    }
    for (int i = z; i <= y; i++)
      if (a[i] == 0) num++;
    cout << num << endl;
  }
  return 0;
}
