#include <bits/stdc++.h>
int main() {
  int t;
  std::cin >> t;
  while (t--) {
    int n;
    std::cin >> n;
    int counter = 0;
    int suffix = 0;
    bool start = false;
    while (n--) {
      int x;
      std::cin >> x;
      if (x) {
        suffix = 0;
        start = true;
      } else if (start) {
        ++counter;
        ++suffix;
      }
    }
    std::cout << (counter - suffix) << '\n';
  }
  return 0;
}
