#include <bits/stdc++.h>
using namespace std;
void debug_vec(vector<long long>& v) {
  cout << '[';
  for (auto i : v) cout << i << ", ";
  cout << "]";
  cout << "\n";
}
void debug_set(set<long long>& st) {
  cout << "{";
  for (auto i : st) cout << i << ", ";
  cout << "}";
  cout << "\n";
}
void fast() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
bool prime[1000001];
void sieve() {
  memset(prime, true, sizeof(prime));
  prime[1] = false;
  for (int p = 2; p * p <= 1000000; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= 1000000; i += p) prime[i] = false;
    }
  }
}
void print(bool f) {
  if (f)
    cout << "YES\n";
  else
    cout << "NO\n";
}
void google(int x) { cout << "Case #" << x << ": "; }
void solve() {
  long long n;
  cin >> n;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  long long skip_count = 0;
  if (a[0] == 1) {
    skip_count++;
  }
  for (int i = 1; i < n;) {
    if (a[i] == 0) {
      i += 1;
      continue;
    } else {
      int count = 0;
      int j = i;
      while (j < n && a[j] == 1) {
        j++;
        count++;
      }
      skip_count += (count / 3);
      i = j;
    }
  }
  cout << skip_count << '\n';
}
int main() {
  fast();
  long long t;
  cin >> t;
  for (int tt = 1; tt <= t; tt++) solve();
  return 0;
}
