#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long tt;
  cin >> tt;
  while (tt--) {
    long long n;
    cin >> n;
    vector<long long> a(n);
    for (long long i = 0; i < n; ++i) cin >> a[i];
    long long ans = 0;
    if (a[0]) ans++;
    long long cnt = 0;
    for (long long i = 1; i < n; ++i) {
      if (a[i])
        cnt++;
      else {
        ans += cnt / 3;
        cnt = 0;
      }
    }
    ans += cnt / 3;
    cout << ans << '\n';
  }
}
