#include <bits/stdc++.h>
using namespace std;
long long dp[200005][2];
long long n;
long long a[200005];
long long fun(long long idx, bool turn) {
  if (idx > n) return 1e9;
  if (idx == n) return 0;
  long long &ret = dp[idx][turn];
  if (~ret) return ret;
  if (!turn) {
    return ret = min(a[idx] + fun(idx + 1, 1),
                     a[idx] + a[idx + 1] + fun(idx + 2, 1));
  }
  return ret = min(fun(idx + 1, 0), fun(idx + 2, 0));
}
signed main() {
  long long t;
  cin >> t;
  while (t--) {
    cin >> n;
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
      dp[i][0] = dp[i][1] = -1;
    }
    cout << fun(0, 0) << endl;
  }
  return 0;
}
