#include <bits/stdc++.h>
int main() {
  using namespace std;
  int T = 1;
  scanf("%d", &T);
  while (T--) {
    int N, first, last;
    scanf("%d", &N);
    vector<int> d(N);
    for (int i = 0; i < N; ++i) {
      scanf("%d", &d[i]);
    }
    for (int i = 0; i < N; ++i) {
      if (d[i] == 1) {
        first = i;
        break;
      }
    }
    for (int i = N - 1; i >= 0; --i) {
      if (d[i] == 1) {
        last = i;
        break;
      }
    }
    int res = 0;
    for (int i = first; i < last; ++i) {
      if (d[i] == 0) {
        ++res;
      }
    }
    printf("%d\n", res);
  }
  return 0;
}
