#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int tt;
cin>>tt;
while(tt--){
int n;
cin>>n;
vector<int> a(n+1);
int ans = 0;
for(int i = 1; i <= n; i++){
cin>>a[i];
if(a[i] > 4){
ans++;
a[i] = 0;
}
else if(a[i] & 1){
a[i]++;
}
}
bool t = 0;
int ms = 0;
for(int i = 1; i <= n; i++){
if(a[i] != 0){
ans++;
if(a[i] == 2){
if(!t){
t = 1;
}
else{
t = 0;
if(ms % 2 == 0){
ans--;
}
ms = 0;
}
}
else{
if(t){
ms++;
}
}
}
else{
t = 0;
ms = 0;
}
}
cout<<ans<<"\n";
}
return 0;
}