#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int a[N], n;
int dp[N][2];
int solve(int idx, int player) {
  if (idx >= n) return 0;
  if (dp[idx][player] != -1) return dp[idx][player];
  int op1 = solve(idx + 1, 1 - player) + (player * a[idx]);
  int op2 = solve(idx + 2, 1 - player) + ((player) * (a[idx] + a[idx + 1]));
  return dp[idx][player] = min(op1, op2);
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    memset(dp, -1, sizeof(dp));
    cout << solve(0, 1) << endl;
  }
  return 0;
}
