#include <bits/stdc++.h>
using namespace std;
int n;
int arr[200005];
int dp[200005][2];
int fun(int pos, int nw) {
  if (pos == n) {
    return 0;
  }
  if (dp[pos][nw] != -1) return dp[pos][nw];
  int res = 1e7;
  if (nw == 0) {
    res = min(res, arr[pos] + fun(pos + 1, nw ^ 1));
    if ((pos + 1) < n) {
      res = min(res, arr[pos] + arr[pos + 1] + fun(pos + 2, nw ^ 1));
    }
  } else {
    res = min(res, fun(pos + 1, nw ^ 1));
    if ((pos + 1) < n) {
      res = min(res, fun(pos + 2, nw ^ 1));
    }
  }
  return dp[pos][nw] = res;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
    }
    for (int i = 0; i <= n; i++) {
      dp[i][0] = -1;
      dp[i][1] = -1;
    }
    cout << fun(0, 0) << endl;
  }
  return 0;
}
