#include <bits/stdc++.h>
using namespace std;
long long T, n, w, m, nn, mm, ma, mb, h, r, l, i, j, ii, jj, x[1000001],
    y[1000001], z, g, aa, bb, a, b, c, d[1000001][2], vis, k, mod = 998244353,
                                                              q, inf = 1e12;
vector<long long> v, vv;
vector<long long> vvv;
queue<pair<long long, long long> > qq;
pair<long long, long long> p;
map<long long, long long> mp, mpp, mppp;
set<pair<long long, long long> > se, see;
set<pair<long long, long long> >::iterator it, itt;
string s, t;
char cc;
long long dp(long long i, long long a) {
  if (i >= n) return 0;
  if (d[i][a] != -1) return d[i][a];
  long long p2 = 1e18;
  long long p1 = dp(i + 1, (a + 1) % 2) + x[i] * a;
  if (i < n - 1) p2 = dp(i + 2, (a + 1) % 2) + (x[i] + x[i + 1]) * a;
  return d[i][a] = min(p1, p2);
}
int main() {
  ios::sync_with_stdio(0);
  cin >> T;
  while (T--) {
    cin >> n;
    for (i = 0; i < n; i++) {
      cin >> x[i];
      d[i][0] = -1;
      d[i][1] = -1;
    }
    cout << dp(0, 1);
    cout << endl;
  }
  return 0;
}
