#include <bits/stdc++.h>
using namespace std;
void Solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &it : a) cin >> it;
  int ans = 0;
  ans += a[0] == 1;
  for (int i = 1; i < n; ++i) {
    if (a[i] == 0) {
      continue;
    }
    int j = i;
    while (j < n && a[j] == 1) {
      ++j;
    }
    ans += (j - i) / 3;
    i = j - 1;
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  cin >> t;
  while (t--) {
    Solve();
  }
  return 0;
}
