#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n, m, T;
int A[maxn], dp[maxn][2];
int f(int x, int q) {
  if (x == 0 && q == 0)
    return 0;
  else if (x <= 0)
    return 1 << 29;
  if (dp[x][q] != -1) return dp[x][q];
  if (q == 0) {
    if (x >= 2)
      dp[x][0] = min(f(x - 2, 1), f(x - 1, 1));
    else
      dp[x][0] = f(x - 1, 1);
    return dp[x][0];
  } else {
    if (x >= 2)
      dp[x][1] = min(f(x - 2, 0) + A[x] + A[x - 1], f(x - 1, 0) + A[x]);
    else
      dp[x][1] = f(x - 1, 0) + A[x];
    return dp[x][1];
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> T;
  while (T--) {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
      cin >> A[i];
    }
    for (int i = 0; i <= n; ++i) {
      dp[i][0] = dp[i][1] = -1;
    }
    cout << min(f(n, 0), f(n, 1)) << endl;
  }
  return 0;
}
