#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n];
    int cnt = 0, fg = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (i == 0 and a[0] == 1) fg = 1;
      if (a[i])
        cnt++;
      else {
        if (fg) {
          fg = 0;
          ans += cnt / 3;
          if (cnt % 3) ans++;
        } else {
          ans += cnt / 3;
        }
        cnt = 0;
      }
    }
    if (fg) {
      fg = 0;
      ans += cnt / 3;
      if (cnt % 3) ans++;
    } else {
      ans += cnt / 3;
    }
    cnt = 0;
    cout << ans << "\n";
  }
  return 0;
}
