#include <string.h>
#include <assert.h>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <time.h>

#include <sstream>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <set>
 
#include <map>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cassert>
//#include<bits/stdc++.h>

 
#define ll long long
#define ull unsigned long long
#define clr(x) memset(x,0,sizeof(x))
#define _clr(x) memset(x,-1,sizeof(x))
#define fr(i,a,b) for(int i = a; i < b; ++i)
#define frr(i,a,b) for(int i = a; i > b; --i)
#define pb push_back
#define sf scanf
 
#define pf printf
#define mp make_pair
#define pir pair<int,int>
#define N 211100
 
using namespace std;

int sum[N];
int a[N];
int n;
int dp[3100][3100];

int get_min(int a, int b){
	return a==-1? b: (b==-1?a:min(a,b));
}

int get(int x){
	int s = 0;
	while(x>0){
		s+=sum[x];
		x-=x&-x;
	}
	return s;
}

void add(int x){
	for(; x<=n; x+=x&-x){
		sum[x]++;
	}
}

int ct(int r){
	return get(n) - get(r-1);
}

int main(){
	int t;
	cin>>t;
	while(t--){
		cin>>n;
		fr(i,1,n+1){
			cin>>a[i];
		}
		fr(i,1,n+1) fr(j,1,n+1) dp[i][j] = -1;
		fr(i,1,n+1) dp[1][i] = 0;
		int ans = -1;
		fr(i,2,n+1) {
			int cnt = 0;
			for(int j = i-1; j ; j--){
				if(j+a[j]>=i){
					if(dp[j][i-1]>=0){
						dp[i][j+a[j]] = get_min(dp[i][j+a[j]], dp[j][i-1] + cnt);
					}
					//printf("i = %d j = %d dp = %d cnt = %d\n",i,j+a[j],dp[i][j+a[j]], cnt);
					cnt++;
					if(i==n){
						ans = get_min(ans,dp[i][j+a[j]]);
					}
				}
			}
			fr(j,i+1,n+1) {
				dp[i][j] = get_min(dp[i][j],dp[i][j-1]);
			}
		}
		cout<<ans<<endl;
	}
}

