#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long double eps = 1e-9;
const long long maxn = 1e5 + 1;
const long long inf = LLONG_MAX;
const long long minf = LLONG_MIN;
bool solve() {
  long long n;
  cin >> n;
  vector<long long> v(n);
  for (long long i = 0; i < n; ++i) cin >> v[i];
  long long cnt = 0, ans = 0, i = 0;
  while (i < n && v[i]) {
    cnt++, i++;
  }
  ans += (cnt + 2) / 3;
  cnt = 0;
  for (; i < n; ++i) {
    if (v[i])
      cnt++;
    else {
      ans += cnt / 3;
      cnt = 0;
    }
  }
  ans += cnt / 3;
  cout << ans << "\n";
  return true;
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) {
    if (solve()) {
    } else {
    }
  }
  return 0;
}
