#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T &x) {
  x = 0;
  char o, f = 1;
  while (o = getchar(), o < 48)
    if (o == 45) f = -f;
  do x = (x << 3) + (x << 1) + (o ^ 48);
  while (o = getchar(), o > 47);
  x *= f;
}
int cansel_sync = (ios::sync_with_stdio(0), cin.tie(0), 0);
long long gcd(long long a, long long b) {
  while (b ^= a ^= b ^= a %= b)
    ;
  return a;
}
const int MAXN = 2e5 + 5;
int a[MAXN];
int dp[MAXN];
int n;
void solve(int z) {
  cin >> n;
  dp[0] = 0x3f3f3f3f;
  for (int i = (1); i <= (n); i++) {
    cin >> a[i];
    dp[i] = 0x3f3f3f3f;
  }
  dp[1] = a[1];
  dp[2] = a[1] + a[2];
  for (int i = (3); i <= (n); i++) {
    dp[i] = dp[i - 2] + a[i];
    dp[i] = min(dp[i], dp[i - 3] + a[i - 1] + a[i]);
    if (i < 4) continue;
    dp[i] = min(dp[i], dp[i - 3] + a[i]);
    dp[i] = min(dp[i], dp[i - 4] + a[i] + a[i - 1]);
  }
  int res = dp[n];
  if (n > 2) res = min(res, dp[n - 2]);
  if (n > 1) res = min(res, dp[n - 1]);
  cout << res << endl;
}
int main() {
  int z;
  cin >> z;
  for (int i = (1); i <= (z); i++) solve(i);
}
