#include <bits/stdc++.h>   using namespace std;   const int64_t MAXN = 1000005;   const int64_t MAXINT = 2147483098;   const int64_t MAXLL = 9223372036854775258LL;   const int64_t MOD = 1e9 + 7;   void solve() {     int64_t n;     cin >> n;     vector<int64_t> a(n + 2);     for (int64_t i = 1; i < n + 1; ++i) cin >> a[i];     int64_t ans = a[1];     int64_t temp = 1;     for (int64_t i = 3; i < n + 1; ++i) {       if (a[i] == 1 && a[i] == a[i - 1])         temp++;       else {         ans += temp / 3;         temp = 1;       }     }     ans += temp / 3;     cout << ans <<   n ;   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int64_t t;     cin >> t;     while (t--) solve();     ;     return 0;   }   