#include <bits/stdc++.h>
using namespace std;
int msb(long long x) {
  union {
    double a;
    int32_t b[2];
  };
  a = x;
  return (b[1] >> 20) - 1023;
}
void sol() {
  int n, b = 0;
  cin >> n;
  vector<int> a(n);
  for (int i = (0); i < (n); i++) cin >> a[i];
  for (int i = (1); i < (n); i++) {
    if (a[i])
      b++;
    else
      b = 0;
    if (b == 3) a[0]++, b = 0;
  }
  cout << a[0] << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  cin >> t;
  while (t--) sol();
}
