#include<bits/stdc++.h>
#define FOR(i,a,b) for(register int i=(a);i<=(b);i++)
#define REP(i,a,b) for(register int i=(a);i>=(b);i--)
#define pb push_back
#define fi first
#define se second
#define hvie '\n'
#define debug cerr<<("QAQ")<<hvie
const int inf=0x3f3f3f3f;
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
int yh(){
	int ret=0;bool f=0;char c=getchar();
	while(!isdigit(c)){if(c==EOF)return -1;if(c=='-')f=1;c=getchar();}
	while(isdigit(c))ret=(ret<<3)+(ret<<1)+(c^48),c=getchar();
	return f?-ret:ret;
}
template<typename T>
void yh(T&ret){
	ret=0;bool f=0;char c=getchar();
	while(!isdigit(c)){if(c==EOF)return ret=-1,void();if(c=='-')f=1;c=getchar();}
	while(isdigit(c))ret=(ret<<3)+(ret<<1)+(c^48),c=getchar();
	ret=f?-ret:ret;
}
int n;
int dp[3003][3003];
int a[3003];
int main(){
	REP(_,yh(),1){
		n=yh();
		FOR(i,1,n) a[i]=yh();
		dp[1][1]=0;
		FOR(i,2,n){
			int cnt=0;
			FOR(j,i,n) dp[i][j]=inf;
			REP(j,i-1,1)if(j+a[j]>=i){
				dp[i][j+a[j]]=min(dp[i][j+a[j]],dp[j][i-1]+cnt);
				cnt++;
			}
			FOR(j,i+1,n) dp[i][j]=min(dp[i][j],dp[i][j-1]);
			// FOR(j,i,n)printf("(%d,%d)=%d\n",i,j,dp[i][j]);
		}
		cout<<dp[n][n]<<hvie;
	}
	return 0;
}
