#include <bits/stdc++.h>
using namespace std;
int read() {
  int num = 0;
  bool f = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    f = (ch == '-');
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    num = (num << 1) + (num << 3) + ch - '0';
    ch = getchar();
  }
  return f ? -num : num;
}
int n, t, op, ans;
int a[222222];
int work() {
  n = read();
  ans = 0;
  t = 1;
  op = 0;
  for (int(i) = (1); (i) <= (n); (i)++) a[i] = read();
  while (t <= n) {
    if (!op) {
      if (a[t])
        t++, ans++;
      else
        t++;
      if (!a[t]) t++;
    } else {
      if (a[t]) t++;
      if (a[t]) t++;
    }
    op ^= 1;
  }
  return printf("%d\n", ans);
}
int main() {
  for (int(_) = (read()); (_) >= (1); (_)--) {
    work();
  }
  return 0;
}
