#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  return b ? gcd(b, a % b) : a;
}
long long int lcm(long long int a, long long int b) {
  return a * (b / gcd(a, b));
}
long long int modpower(long long int x, long long int y, long long int m) {
  if (y == 0) return 1;
  long long int p = modpower(x, y / 2, m) % m;
  p = (p * p) % m;
  return (y % 2 == 0) ? p : (x * p) % m;
}
long long int power(long long int a, long long int b) {
  long long int ans = 1;
  while (b) {
    if (b & 1) ans = ans * a;
    a = a * a;
    b >>= 1;
  }
  return ans;
}
bool isPrime(long long int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
long long int a[200001];
long long int n;
map<pair<long long int, long long int>, long long int> m;
long long int rec(long long int p, long long int turn) {
  if (p > n - 1) return 0;
  if (m.find({p, turn}) != m.end()) return m[{p, turn}];
  if (turn == 0) {
    if (p < n - 1)
      m[{p, turn}] = min(a[p] + rec(p + 1, 1), a[p] + a[p + 1] + rec(p + 2, 1));
    else
      m[{p, turn}] = a[p] + rec(p + 1, 1);
  } else {
    m[{p, turn}] = min(rec(p + 1, 0), rec(p + 2, 0));
  }
  return m[{p, turn}];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    cin >> n;
    m = map<pair<long long int, long long int>, long long int>();
    for (long long int i = 0; i < n; i++) cin >> a[i];
    long long int m = rec(0, 0);
    cout << m << "\n";
  }
}
