#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using Pii = pair<int, int>;
using Pll = pair<LL, LL>;
using VI = vector<int>;
using VP = vector<pair<int, int>>;
constexpr int maxn = 201000;
int a[maxn], f[maxn][2];
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n;
    scanf("%d", &n);
    for (auto i = (0); i < (n); ++i) scanf("%d", &a[i]);
    if (n == 1) {
      printf("%d\n", a[0]);
      continue;
    }
    f[0][0] = n;
    f[0][1] = a[0];
    f[1][0] = a[0];
    f[1][1] = a[0] + a[1];
    for (auto i = (2); i < (n); ++i) {
      f[i][0] = min(f[i - 1][1], f[i - 2][1]);
      f[i][1] = min(f[i - 1][0] + a[i], f[i - 2][0] + a[i] + a[i - 1]);
    }
    printf("%d\n", min(f[n - 1][0], f[n - 1][1]));
  }
}
