#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5;
const long long inf = 1e9;
const long long mod = 1e9 + 7;
inline long long read() {
  register long long s = 0;
  register bool neg = 0;
  register char c = getchar();
  for (; c < '0' || c > '9'; c = getchar()) neg |= (c == '-');
  for (; c >= '0' && c <= '9'; s = s * 10 + (c ^ 48), c = getchar())
    ;
  return (neg ? -s : s);
}
long long t, a, s[N + 10], dp[N + 10][2];
signed main() {
  t = read();
  while (t--) {
    a = read();
    for (long long i = 0; i <= a; i++) dp[i][0] = dp[i][1] = inf;
    dp[0][0] = 0;
    for (long long i = 1; i <= a; i++) s[i] = read();
    for (long long i = 1; i <= a; i++) {
      dp[i][1] =
          min(dp[i - 1][0], dp[i - min(i, 1ll * 2)][0] + s[i - 1]) + s[i];
      dp[i][0] = min(dp[i - 1][1], dp[i - min(i, 1ll * 2)][1]);
    }
    printf("%lld\n", min(dp[a][0], dp[a][1]));
  }
  return 0;
}
