#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     int T;     cin >> T;     while (T--) {       int N;       cin >> N;       vector<int> a(N);       ;       for (int& x : a) cin >> x;       int ans = (a[0] == 1);       for (int i = 1; i < N; ++i) {         if (a[i] == 0) continue;         int j = i;         while (j < N && a[j] == 1) ++j;         ans += (j - i) / 3;         i = j - 1;       }       cout << ans <<   n ;     }   }   