#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t, n, l, r;
  cin >> t;
  while (t--) {
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
      if (a[i] == 1) {
        l = i;
        break;
      }
    }
    for (int i = n - 1; i >= 0; i--) {
      if (a[i] == 1) {
        r = i;
        break;
      }
    }
    int ans = 0;
    for (int i = l; i < r + 1; i++) {
      if (a[i] == 0) ans++;
    }
    cout << ans << endl;
  }
  return 0;
}
