#include <bits/stdc++.h>
using namespace std;
int n;
int a[200001], dp[200001][2];
int rec(int i, int cur) {
  if (i > n) return 0;
  if (dp[i][cur] != -1) return dp[i][cur];
  int ans = 20000000;
  if (!cur) {
    ans = min(ans, a[i] + rec(i + 1, 1));
    if (i < n - 1) ans = min(ans, a[i] + a[i + 1] + rec(i + 2, 1));
  } else {
    ans = min(ans, rec(i + 1, 0));
    ans = min(ans, rec(i + 2, 0));
  }
  return dp[i][cur] = ans;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 1; i <= n; i++) dp[i][0] = dp[i][1] = -1;
    for (int i = 1; i <= n; i++) cin >> a[i];
    cout << rec(1, 0) << '\n';
  }
}
