#include <bits/stdc++.h>
using namespace std;
double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int diry[8] = {0, 1, -1, 0, -1, 1, -1, 1};
const long long MOD = 1000000007;
long long sum() { return 0; }
template <typename T, typename... Args>
T sum(T a, Args... args) {
  return a + sum(args...);
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &(z) : a) cin >> z;
  ;
  while (a.back() == 0) a.pop_back();
  reverse(a.begin(), a.end());
  while (a.back() == 0) a.pop_back();
  int ans = 0;
  for (auto &(x) : (a)) ans += (x == 0);
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc;
  cin >> tc;
  while (tc--) solve();
  return 0;
}
