#include <bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()), ((v).end())
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define B begin()
#define E end()
#define clr(x) memset(x,0,sizeof(x))
#define endl '\n'
#define coutfloat(n,d) cout << fixed << setprecision(d) << n << endl
#define FASTIO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
// #define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector< vi > vvi;
#ifndef ONLINE_JUDGE
#define deb(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define deb(x)
#endif
void _print(ll t) {cerr << t;}
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(ld t) {cerr << t;}
void _print(double t) {cerr << t;}
void _print(ull t) {cerr << t;}
template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.F); cerr << ","; _print(p.S); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}
const int dx[] = {0,0,1,-1};
const int dy[] = {1,-1,0,0};
const ll inf = 1e9+1000;
const double eps = (1e-8);
const ll mod = 1e9 + 7;
const int N = 2e5+1000, M = 10;
int k,n,m;
vi a;
ll dp[N][2]={};
ll getMin(int ind, int del){
if(ind>=n) return 0;
if(dp[ind][del]!=-1) return dp[ind][del];
ll ans = inf;
deb(ind) deb(del)
if(a[ind] - 2*del<=0){
return dp[ind][del]= min(getMin(ind+1, 0), getMin(ind+1, 1) + 1);
}
else{
ans = getMin(ind+1, 0);
if(a[ind] -2* del <= 2){
ans = min(ans, getMin(ind+1, 1));
}
return dp[ind][del] = ans+1;
}
}
void solve(){
cin>>n;
rep(i,0,2){
rep(j,0,n+10){
dp[j][i]=-1;
}
}
a = vi(n);
rep(i,0,n) cin>>a[i];
cout<<getMin(0,0)<<endl;;
// deb("n")
}
// #undef int;
int main(){
FASTIO;
int t= 1;
cin>>t;
while(t--) solve();
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgoKI2RlZmluZSBhbGwodikgICAgICAgICgodikuYmVnaW4oKSksICgodikuZW5kKCkpCiNkZWZpbmUgcmVwKGksIGJlZ2luLCBlbmQpIGZvciAoX190eXBlb2YoZW5kKSBpID0gKGJlZ2luKSAtICgoYmVnaW4pID4gKGVuZCkpOyBpICE9IChlbmQpIC0gKChiZWdpbikgPiAoZW5kKSk7IGkgKz0gMSAtIDIgKiAoKGJlZ2luKSA+IChlbmQpKSkKI2RlZmluZSBwYiAgICAgICAgICAgIHB1c2hfYmFjawojZGVmaW5lIHBwYiAgICAgICAgICAgcG9wX2JhY2sKI2RlZmluZSBGICAgICAgICAgICAgIGZpcnN0CiNkZWZpbmUgUyAgICAgICAgICAgICBzZWNvbmQKI2RlZmluZSBCICAgICAgICAgICAgIGJlZ2luKCkKI2RlZmluZSBFICAgICAgICAgICAgIGVuZCgpCiNkZWZpbmUgY2xyKHgpICAgICAgICBtZW1zZXQoeCwwLHNpemVvZih4KSkKI2RlZmluZSBlbmRsICAgICAgICAgICdcbicKI2RlZmluZSBjb3V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oYXV0byBpIDogdikge19wcmludChpKTsgY2VyciA8PCAiICI7fSBjZXJyIDw8ICJdIjt9Cgpjb25zdCBpbnQgZHhbXSA9IHswLDAsMSwtMX07CmNvbnN0IGludCBkeVtdID0gezEsLTEsMCwwfTsKCmNvbnN0IGxsIGluZiA9IDFlOSsxMDAwOwpjb25zdCBkb3VibGUgZXBzID0gKDFlLTgpOwpjb25zdCBsbCBtb2QgPSAxZTkgKyA3OwoKY29uc3QgaW50IE4gPSAyZTUrMTAwMCwgTSA9IDEwOwppbnQgayxuLG07CnZpIGE7CmxsIGRwW05dWzJdPXt9OwpsbCBnZXRNaW4oaW50IGluZCwgaW50IGRlbCl7CiAgICBpZihpbmQ+PW4pIHJldHVybiAwOwogICAgaWYoZHBbaW5kXVtkZWxdIT0tMSkgcmV0dXJuIGRwW2luZF1bZGVsXTsKICAgIGxsIGFucyA9IGluZjsKICAgIGRlYihpbmQpIGRlYihkZWwpCiAgICBpZihhW2luZF0gLSAyKmRlbDw9MCl7CiAgICAgICAgcmV0dXJuIGRwW2luZF1bZGVsXT0gbWluKGdldE1pbihpbmQrMSwgMCksIGdldE1pbihpbmQrMSwgMSkgKyAxKTsKICAgIH0KICAgIGVsc2V7CiAgICAgICAgYW5zID0gZ2V0TWluKGluZCsxLCAwKTsKICAgICAgICBpZihhW2luZF0gLTIqIGRlbCA8PSAyKXsKICAgICAgICAgICAgYW5zID0gbWluKGFucywgZ2V0TWluKGluZCsxLCAxKSk7CiAgICAgICAgfQogICAgICAgIHJldHVybiBkcFtpbmRdW2RlbF0gPSBhbnMrMTsKICAgIH0KICAgIAp9CnZvaWQgc29sdmUoKXsKICAgIGNpbj4+bjsKICAgIHJlcChpLDAsMil7CiAgICAgICAgcmVwKGosMCxuKzEwKXsKICAgICAgICAgICAgZHBbal1baV09LTE7CiAgICAgICAgfQogICAgfQogICAgYSA9IHZpKG4pOwogICAgcmVwKGksMCxuKSBjaW4+PmFbaV07CiAgICBjb3V0PDxnZXRNaW4oMCww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