#include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
int a[maxn];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    int ans = 0, cnt = 0;
    bool flag = false;
    for (int i = 1; i <= n; i++) {
      if (a[i] == 1) {
        if (flag) ans += cnt;
        cnt = 0;
        flag = true;
      }
      if (a[i] == 0) cnt++;
    }
    cout << ans << '\n';
  }
  return 0;
}
