#include <bits/stdc++.h>
using namespace std;
int a[500];
int main() {
  int n, t;
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    int f = 0, sum = 0, ans = 0;
    for (int i = 1; i <= n; i++) {
      if (!f && a[i] == 1) {
        f = i;
        ans++;
      } else if (a[i] == 1 && f) {
        sum += i - f - 1;
        f = i;
        ans++;
      }
    }
    if (ans == 1) sum = 0;
    cout << sum << endl;
  }
}
