#include<bits/stdc++.h>
using namespace std;
const int N=3510;
int t, n, a[N], dp[N][N];
int main(){
  ios::sync_with_stdio(0);
  cin>>t;
  while (t){
	t--;
	cin>>n;
	for (int i=1; i<=n; i++) cin>>a[i];
	for (int i=2; i<=n; i++){
		for (int j=1; j<=n; j++) dp[i][j]=1e9;
		int cnt = 0;
		for (int j=i-1; j>=1; j--){
			if (j+a[j]>=i){
				dp[i][j+a[j]]=min(dp[i][j+a[j]], dp[j][i-1]+cnt);
				cnt++;
			}
		}
		for (int j=i+1; j<=n; j++) dp[i][j]=min(dp[i][j], dp[i][j-1]);
	}
	cout<<dp[n][n]<<endl;
  }
}