#include <bits/stdc++.h>
using namespace std;
const int N = 100010, M = 1010;
int T;
int n, a[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  cin >> T;
  while (T--) {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    int l, r;
    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 cnt = 0;
    for (int i = l; i <= r; i++)
      if (a[i] == 1) cnt++;
    cout << r - l + 1 - cnt << '\n';
  }
  return 0;
}
