#include <bits/stdc++.h>
using namespace std;
int dp[200010][2], a[200010];
int n;
void solve() {
  for (int i = 1; i <= n + 2; i++) {
    dp[i][0] = dp[i][1] = 1000000007;
  }
  dp[1][0] = 0;
  for (int i = 1; i <= n; i++) {
    dp[i + 2][0] = min(dp[i][1], dp[i + 2][0]);
    dp[i + 1][0] = min(dp[i][1], dp[i + 1][0]);
    if (a[i] == 1) {
      if (a[i + 1] == 0)
        dp[i + 2][1] = min(dp[i][0] + 1, dp[i + 2][1]);
      else
        dp[i + 2][1] = min(dp[i][0] + 2, dp[i + 2][1]);
      dp[i + 1][1] = min(dp[i][0] + 1, dp[i + 1][1]);
    } else {
      if (a[i + 1] == 0)
        dp[i + 2][1] = min(dp[i][0], dp[i + 2][1]);
      else
        dp[i + 2][1] = min(dp[i][0] + 1, dp[i + 2][1]);
      dp[i + 1][1] = min(dp[i][0], dp[i + 1][1]);
    }
  }
  cout << min(dp[n + 1][0], dp[n + 1][1]) << endl;
}
int main() {
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    solve();
  }
}
