#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
struct HASH {
  size_t operator()(const pair<int, int>& x) const {
    return hash<long long>()(((long long)x.first) ^
                             (((long long)x.second) << 32));
  }
};
string inttostr(long long int n) {
  std::stringstream ss;
  ss << n;
  string out = ss.str();
  return out;
}
long long int stringtoint(string s) {
  istringstream iss(s);
  long long int n;
  iss >> n;
  return n;
}
template <typename T>
T gcd(T a, T b) {
  if (a < 0) return gcd(-a, b);
  if (b < 0) return gcd(a, -b);
  return (b == 0) ? a : gcd(b, a % b);
}
template <typename T>
T lcm(T a, T b) {
  if (a < 0) return lcm(-a, b);
  if (b < 0) return lcm(a, -b);
  return a * (b / gcd(a, b));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int testsalam;
  cin >> testsalam;
  while (testsalam--) {
    int n;
    cin >> n;
    int arr[n + 10];
    for (long long int i = 0; i < n; i++) cin >> arr[i];
    ;
    int got = 0;
    int ans = 0;
    std::vector<int> v;
    for (int i = 0; i < n; ++i) {
      if (arr[i]) v.push_back(i);
    }
    for (int i = 1; i < (int)v.size(); ++i) {
      ans += (v[i] - v[i - 1] - 1);
    }
    cout << ans << '\n';
  }
}
