#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
void __print(long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  long long f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
const long long N = 2e5;
long long vis[N][2];
vector<long long> a;
long long dp[N][2];
long long n;
long long solve(vector<long long> &a, long long i, long long turn) {
  if (i >= n) return 0;
  if (vis[i][turn]) return dp[i][turn];
  vis[i][turn] = 1;
  if (turn) {
    if (i == n - 1) return dp[i][turn] = 0;
    return (dp[i][turn] = min(solve(a, i + 1, 0), solve(a, i + 2, 0)));
  } else {
    if (i == n - 1) return dp[i][turn] = a[i];
    return (dp[i][turn] = min(a[i] + solve(a, i + 1, 1),
                              a[i] + a[i + 1] + solve(a, i + 2, 1)));
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    cin >> n;
    a.resize(n);
    for (long long i = 0; i < (n); i++) {
      for (long long j = 0; j < (2); j++) {
        dp[i][j] = 0;
        vis[i][j] = 0;
      }
    }
    for (long long i = 0; i < (n); i++) {
      cin >> a[i];
    }
    cout << solve(a, 0, 0) << "\n";
  }
}
