#include<cstdio>
#include<iostream> 
#include<queue>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long
#define go(i,x,a) for(int i=a;i<x;i++)
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
#define lowbit(x) (x&(-x))
using namespace std;

const int maxn=3e3+5;
int n,m,p[maxn],f[maxn][maxn],t[maxn];

inline int rd(){
	int ret=0,af=1; char gc=getchar();
	while(gc < '0' || gc > '9'){ if(gc == '-') af=-af; gc=getchar(); }
	while(gc >= '0' && gc <= '9') ret=ret*10+gc-'0',gc=getchar();
	return ret*af;
}

inline void gmax(int &a,int b){
	if(a < b) a=b; return ; 
}

inline void gmin(int &a,int b){
	if(a > b) a=b; return ;
}

inline void add(int x){
	for(int i=x;i<=n;i+=lowbit(i)) t[i]++;
	return ;
}

inline int query(int x){
	int ss=0;
	for(int i=x;i>0;i-=lowbit(i)) ss+=t[i];
	return ss;
}

int main(){
	int T=rd();
	while(T--){
		n=rd(); int ans=0,ss=0;
		go(i,n+5,1) go(j,n+5,1) f[i][j]=0;
		go(i,n+1,1){
		 	p[i]=rd(); ss+=p[i] > 0;
			if(i != n) gmin(p[i],n-i);
		}
		//if(p[n] == 0) p[n]=1,ss++;
		go(i,n+1,1) t[i]=0;
		f[n][n+1]=1;
		for(int i=n-1;i>=1;i--)
			if(p[i]){
				int ls=i+p[i];
		 		go(j,ls+1,i+1)
		 			if(f[j][ls+1]) gmax(f[i][j],f[j][ls+1]+1+query(j-1));
				for(int j=n;j>=i+1;j--) gmax(f[i][j],f[i][j+1]);
				add(ls);
			}
		go(i,n+1,2) gmax(ans,f[1][i]);
		printf("%d\n",ss-ans+1);
	}
	return 0;
}
