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