#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<vector>
#include<algorithm>
#define fs(i,x,y) for(int i=(x),_=(y);i<=_;++i)
#define fn(i,x,y) for(int i=(x),_=(y);i>=_;--i)
#define tor(i,v,x) for(int i=head[x],v=to[i];i;i=nxt[i],v=to[i])
#define Li inline
#define R register int
#define ls(x) ch[x][0]
#define rs(x) ch[x][1]
#define mpi(x,y) make_pair(x,y)
#define pi pair<int,int>
//#define int ll 
using namespace std;
typedef long long ll;
template<typename T>
void read(T &x){
	x=0;char ch=getchar();bool f=0;
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
	x=f?-x:x;
}

const int N=3005;
const int inf=1e9+7;
int n,m;
int dp[N][N];
int a[N];

signed main(){
	int T;read(T);while(T--){
		read(n);fs(i,1,n)read(a[i]);
		fs(i,2,n){
			int cnt=0;
			fs(j,2,n)dp[i][j]=inf;
			fn(j,i-1,1){
				if(j+a[j]<i)continue;
				dp[i][j+a[j]]=min(dp[i][j+a[j]],dp[j][i-1]+cnt);++cnt;
			}
			fs(j,i+1,n)dp[i][j]=min(dp[i][j],dp[i][j-1]);
		}
		printf("%d\n",dp[n][n]);
	}
	return 0;
}