#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long a[n + 5], i, j, k, l, index1 = 0, index2 = 0, cnt = 0;
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (long long i = 0; i < n; i++) {
      if (a[i] == 1) {
        index1 = i;
        break;
      }
    }
    for (long long i = n - 1; i >= 0; i--) {
      if (a[i] == 1) {
        index2 = i;
        break;
      }
    }
    for (long long i = index1; i < index2 + 1; i++) {
      if (a[i] == 0) cnt++;
    }
    cout << cnt << '\n';
  }
  return 0;
}
