#include <bits/stdc++.h>
using namespace std;
long long inv_euclid(long long a, long long m = 998244353) {
  long long m0 = m;
  long long y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    long long q = a / m;
    long long t = m;
    m = a % m, a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long max(long long a, long long b) {
  if (a > b) return a;
  return b;
}
long long min(long long a, long long b) {
  if (a < b) return a;
  return b;
}
long long ssum(long long n) { return (n * (n + 1)) / 2; }
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a * b) / (gcd(a, b)); }
void solve() {
  long long n;
  cin >> n;
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) cin >> v[i];
  while (v.size() && v[v.size() - 1] == 0) v.pop_back();
  reverse(v.begin(), v.end());
  while (v.size() && v[v.size() - 1] == 0) v.pop_back();
  long long ans = 0;
  for (auto i : v) ans += (i == 0);
  cout << ans << "\n";
}
int main() {
  long long tttt;
  cin >> tttt;
  while (tttt--) {
    solve();
  }
}
