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