#include <bits/stdc++.h>
using namespace std;
bool b[200005];
int t, N, d[200005][2];
int solve(int n, bool p) {
  if (n == N) d[n][p] = 0;
  if (d[n][p] == -1) {
    if (p == 0) {
      d[n][p] = b[n] + solve(n + 1, !p);
      if (n + 1 < N) d[n][p] = min(d[n][p], b[n] + b[n + 1] + solve(n + 2, !p));
    } else {
      d[n][p] = solve(n + 1, !p);
      if (n + 1 < N) d[n][p] = min(d[n][p], solve(n + 2, !p));
    }
  }
  return d[n][p];
}
int main() {
  cin >> t;
  while (t--) {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> b[i], d[i][0] = d[i][1] = -1;
    cout << solve(0, 0) << "\n";
  }
}
