#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int maxn = 2e5;
int a[500];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }
    int l, r;
    for (int i = 1; i <= n; i++) {
      if (a[i] == 1) {
        l = i;
        break;
      }
    }
    for (int i = n; i >= 1; i--) {
      if (a[i] == 1) {
        r = i;
        break;
      }
    }
    int ans = 0;
    for (int i = l; i <= r; i++) {
      if (a[i] == 0) ans++;
    }
    cout << ans << endl;
  }
  return 0;
}
