#include <bits/stdc++.h>
using namespace std;
void solve() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];
  int count = 0;
  int ans = 0;
  if (A[0] == 1) ans++;
  for (int i = 1; i < N; ++i) {
    count = 0;
    while (i < N && A[i] == 1) {
      i++;
      count++;
    }
    ans += (count) / 3;
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T;
  cin >> T;
  while (T--) {
    solve();
  }
  return 0;
}
