#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long double pi = acos(-1.0);
long long gcd(long long a, long long b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long binpows(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}
long long binpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return res;
}
const long long mod = 1e9 + 7;
vector<bool> v;
long long n;
const long long N = 2 * 1e5 + 1;
long long dp[N][2];
long long go(long long pos, long long f) {
  if (pos == n) return 0;
  long long &x = dp[pos][f];
  if (x != -1) return x;
  x = INF;
  x = min(x, go(pos + 1, !f) + (v[pos] and f));
  if (pos != n - 1)
    x = min(x, go(pos + 2, !f) + (v[pos] and f) + (v[pos + 1] and f));
  return x;
}
void solve() {
  cin >> n;
  for (long long i = 0; i < n; i++) {
    dp[i][0] = -1;
    dp[i][1] = -1;
  }
  v.resize(n);
  for (long long i = 0; i < n; i++) {
    long long a;
    cin >> a;
    v[i] = a;
  }
  cout << go(0, 1) << endl;
}
signed main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
