#include <bits/stdc++.h>
using namespace std;
multiset<long long> mset;
void add(long long k) { mset.insert(k); }
long long getmin() { return *mset.begin(); }
long long getmax() { return *prev(mset.end()); }
long long lower(long long k) {
  if (mset.size() == 0) return -1;
  if (k < getmin()) return -1;
  if (mset.count(k)) return k;
  auto it = mset.lower_bound(k);
  return *prev(it);
}
long long uper(long long k) {
  if (mset.size() == 0) return -1;
  auto it = mset.lower_bound(k);
  if (it == mset.end()) return -1;
  return *it;
}
void erase(long long k) { mset.erase(mset.find(k)); }
long long t, n;
const long long inf = 0x3f3f3f3f;
long long dp[200005][2], a[200005];
signed main() {
  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    cin >> n;
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
      dp[i][1] = inf;
      dp[i][0] = inf;
    }
    dp[0][0] = a[0];
    dp[1][0] = dp[0][0] + a[1];
    dp[1][1] = dp[0][0];
    for (long long i = 2; i < n; i++) {
      dp[i][0] = min(dp[i - 1][1] + a[i], dp[i - 2][1] + a[i - 1] + a[i]);
      dp[i][1] = min(dp[i - 1][0], dp[i - 2][0]);
    }
    cout << min(dp[n - 1][0], dp[n - 1][1]) << "\n";
  }
  return 0;
}
