#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
const long long inf = 0x3f3f3f3f3f3f3f3f;
inline bool qread(long long& x) {
  x = 0;
  long long f = 1;
  long long ch = getchar();
  if (ch == EOF) return false;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  x *= f;
  return true;
}
const bool file = false;
const string name = "test";
const bool mul = true;
const long long maxn = 2e5 + 11;
long long n;
long long arr[maxn];
long long dp[maxn][2];
inline void init() {}
inline void solve(long long ti) {
  qread(n);
  for (long long i = 1; i <= n; ++i) qread(arr[i]);
  for (long long i = 0; i <= n; ++i) dp[i][0] = dp[i][1] = inf;
  dp[0][0] = 0;
  dp[1][1] = arr[1];
  for (long long i = 2; i <= n; ++i) {
    dp[i][0] = min(dp[i - 1][1], dp[i - 2][1]);
    dp[i][1] = min(dp[i - 1][0] + arr[i], dp[i - 2][0] + arr[i] + arr[i - 1]);
  }
  printf("%lld\n", min(dp[n][0], dp[n][1]));
}
int main() {
  if (file) {
    freopen((name + ".in").c_str(), "r", stdin);
    freopen((name + ".out").c_str(), "w", stdout);
  }
  init();
  if (mul) {
    long long t;
    qread(t);
    for (long long i = 1; i <= t; ++i) solve(i);
  } else
    solve(-1);
  if (file) {
    fclose(stdin);
    fclose(stdout);
  }
  return 0;
}
