#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> arr(n);
    for (int i = 0; i < n; i++) cin >> arr[i];
    int first, last;
    long long ans = 0;
    for (int i = 0; i < n; i++) {
      if (arr[i] == 1) {
        first = i;
        break;
      }
    }
    for (int i = n - 1; i >= 0; i--) {
      if (arr[i] == 1) {
        last = i;
        break;
      }
    }
    for (int i = first; i <= last; i++) {
      if (arr[i] == 0) ans += 1;
    }
    cout << ans << endl;
  }
}
