#include<bits/stdc++.h>
using namespace std;
const int N = 3e3+5;
int n, a[N], dp[N][N];


void run_case()
{
	cin >> n;
	for(int i=0; i<n; i++)
		cin >> a[i];
	
	for(int i=1; i<=n; i++) for(int j=0; j<=n; j++) dp[i][j] = 1e9;
	for(int i=1; i<n; i++)
	{
		int cnt = 0;
		for(int j=i-1; j>=0; 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=1; j<n; j++) dp[i][j] = min(dp[i][j], dp[i][j-1]);
	}
	cout << dp[n-1][n-1] << endl;
}

int main()
{
	#ifdef LOCAL
		freopen("in.txt", "rt", stdin);
		freopen("out.txt", "wt", stdout);
	#endif
	int t;
	cin >> t;
	while(t--)
	{
		run_case();
	}
}
