#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
namespace Backlight {
const int __BUFFER_SIZE__ = 1 << 20;
bool NEOF = 1;
int __top;
char __buf[__BUFFER_SIZE__], *__p1 = __buf, *__p2 = __buf, __stk[996];
template <typename T>
T MIN(T a, T b) {
  return min(a, b);
}
template <typename First, typename... Rest>
First MIN(First f, Rest... r) {
  return min(f, MIN(r...));
}
template <typename T>
T MAX(T a, T b) {
  return max(a, b);
}
template <typename First, typename... Rest>
First MAX(First f, Rest... r) {
  return max(f, MAX(r...));
}
template <typename T>
void updMin(T &a, T b) {
  if (a > b) a = b;
}
template <typename T>
void updMax(T &a, T b) {
  if (a < b) a = b;
}
inline char nc() {
  return __p1 == __p2 && NEOF &&
                 (__p2 =
                      (__p1 = __buf) + fread(__buf, 1, __BUFFER_SIZE__, stdin),
                  __p1 == __p2)
             ? (NEOF = 0, EOF)
             : *__p1++;
}
template <typename T>
inline bool read(T &x) {
  char c = nc();
  bool f = 0;
  x = 0;
  while (!isdigit(c)) c == '-' && (f = 1), c = nc();
  while (isdigit(c)) x = (x << 3) + (x << 1) + (c ^ 48), c = nc();
  if (f) x = -x;
  return NEOF;
}
inline bool need(char c) { return islower(c) || isupper(c) || isdigit(c); }
inline bool read(char &a) {
  while ((a = nc()) && need(a) && NEOF)
    ;
  return NEOF;
}
inline bool read(char *a) {
  while ((*a = nc()) && need(*a) && NEOF) ++a;
  *a = '\0';
  return NEOF;
}
inline bool read(double &x) {
  bool f = 0;
  char c = nc();
  x = 0;
  while (!isdigit(c)) {
    f |= (c == '-');
    c = nc();
  }
  while (isdigit(c)) {
    x = x * 10.0 + (c ^ 48);
    c = nc();
  }
  if (c == '.') {
    double temp = 1;
    c = nc();
    while (isdigit(c)) {
      temp = temp / 10.0;
      x = x + temp * (c ^ 48);
      c = nc();
    }
  }
  if (f) x = -x;
  return NEOF;
}
template <typename T, typename... T2>
inline bool read(T &x, T2 &...rest) {
  read(x);
  return read(rest...);
}
template <typename T>
inline void print(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x == 0) {
    putchar('0');
    return;
  }
  __top = 0;
  while (x) {
    __stk[++__top] = x % 10 + '0';
    x /= 10;
  }
  while (__top) {
    putchar(__stk[__top]);
    --__top;
  }
}
template <typename First, typename... Rest>
inline void print(First f, Rest... r) {
  print(f);
  putchar(' ');
  print(r...);
}
template <typename T>
inline void println(T x) {
  print(x);
  putchar('\n');
}
template <typename First, typename... Rest>
inline void println(First f, Rest... r) {
  print(f);
  putchar(' ');
  println(r...);
}
template <typename T>
inline void _dbg(const char *format, T value) {
  cerr << format << '=' << value << endl;
}
template <typename First, typename... Rest>
inline void _dbg(const char *format, First f, Rest... r) {
  while (*format != ',') cerr << *format++;
  cerr << '=' << f << ", ";
  _dbg(format + 1, r...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[ ";
  for (auto v : V) os << v << ",";
  return os << " ]";
}
template <typename T>
ostream &operator<<(ostream &os, set<T> V) {
  os << "[ ";
  for (auto v : V) os << v << ",";
  return os << " ]";
}
template <typename T>
ostream &operator<<(ostream &os, multiset<T> V) {
  os << "[ ";
  for (auto v : V) os << v << ",";
  return os << " ]";
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> V) {
  os << "[ ";
  for (auto v : V) os << v << ",";
  return os << " ]";
}
template <typename L, typename R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
}  // namespace Backlight
using namespace Backlight;
const int N = 5e4 + 5;
const int M = 1e5 + 5;
const int V = 1e6 + 5;
const long long MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long LLINF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
int n, a[55];
void solve(int Case) {
  read(n);
  for (int i = (1); i <= (n); ++i) read(a[i]);
  vector<pair<int, int> > v;
  for (int i = (1); i <= (n); ++i) {
    if (a[i] == 1) {
      int l = i, r = i;
      while (r + 1 <= n && a[r + 1] == 1) ++r;
      v.push_back(pair<int, int>(l, r));
      i = r;
    }
  };
  int ans = 0;
  for (int c = (1); c < (((int)(v).size())); ++c) {
    ans += v[c].first - v[c - 1].second - 1;
  }
  println(ans);
}
int main() {
  int T = 1;
  read(T);
  for (int _ = 1; _ <= T; _++) solve(_);
  return 0;
}
