#include <bits/stdc++.h>
using namespace std;
void run_case();
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tc = 1;
  cin >> tc;
  for (int i = 1; i <= tc; i++) run_case();
  return 0;
}
const int M = 1000000007;
int n;
vector<int> a;
vector<array<int, 2>> dp;
void run_case() {
  cin >> n;
  a = vector<int>(n);
  for (auto &ii : a) cin >> ii;
  dp = vector<array<int, 2>>(n + 1, {INT_MAX, INT_MAX});
  dp[0][0] = 0;
  for (int i = (0); i < (n + 1); i++) {
    if (dp[i][0] != INT_MAX) {
      if (i + 1 <= n) dp[i + 1][1] = min(dp[i + 1][1], dp[i][0] + (a[i] == 1));
      if (i + 2 <= n)
        dp[i + 2][1] =
            min(dp[i + 2][1], dp[i][0] + (a[i] == 1) + (a[i + 1] == 1));
    }
    if (dp[i][1] != INT_MAX) {
      if (i + 1 <= n) dp[i + 1][0] = min(dp[i + 1][0], dp[i][1]);
      if (i + 2 <= n) dp[i + 2][0] = min(dp[i + 2][0], dp[i][1]);
    }
  }
  cout << min(dp[n][0], dp[n][1]) << "\n";
}
