#include <bits/stdc++.h>
using namespace std;
const int M = 2e5 + 5;
int n, arr[M], dp[M][3];
int solve(int ind, int turn) {
  if (ind == n) return 0;
  if (dp[ind][turn] != -1) return dp[ind][turn];
  int ans = 1e9;
  if (turn == 0) {
    ans = min(ans, solve(ind + 1, 1) + arr[ind]);
    if (ind + 2 <= n) {
      ans = min(ans, solve(ind + 2, 1) + arr[ind] + arr[ind + 1]);
    }
  } else {
    ans = min(ans, solve(ind + 1, 0));
    if (ind + 2 <= n) {
      ans = min(ans, solve(ind + 2, 0));
    }
  }
  return dp[ind][turn] = ans;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
      dp[i][0] = dp[i][1] = -1;
    }
    cout << solve(0, 0) << '\n';
  }
  return 0;
}
