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