#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long fastPow(long long base, long long exp, long long mod) {
  long long res = 1;
  while (exp > 0) {
    if (exp % 2 == 1) res = ((res % mod) * (base % mod)) % mod;
    base = ((base % mod) * (base % mod)) % mod;
    exp /= 2;
  }
  return res % mod;
}
long long a[200005];
long long dp[200005][2];
long long n;
long long solveUtil(long long i, long long turn) {
  if (i >= n) return 0;
  if (dp[i][turn] != -1) return dp[i][turn];
  long long& res = dp[i][turn];
  if (turn)
    res = min(solveUtil(i + 1, 0), solveUtil(i + 2, 0));
  else
    res =
        min(solveUtil(i + 1, 1) + a[i], solveUtil(i + 2, 1) + a[i] + a[i + 1]);
  return res;
}
void solve() {
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    dp[i][0] = dp[i][1] = -1;
  }
  a[n] = a[n + 1] = 0;
  long long ans = solveUtil(0, 0);
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long tc = 1;
  cin >> tc;
  while (tc--) {
    solve();
  }
  return 0;
}
