#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<bitset>
#include<map>
//#include<regex>
#include<cstdio>
#include <iomanip>
#pragma GCC optimize(2)
#define up(i,a,b)  for(int i=a;i<b;i++)
#define dw(i,a,b)  for(int i=a;i>b;i--)
#define upd(i,a,b) for(int i=a;i<=b;i++)
#define dwd(i,a,b) for(int i=a;i>=b;i--)
//#define local
typedef long long ll;
typedef unsigned long long ull;
const double esp = 1e-6;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int inf = 1e9;
using namespace std;
ll read()
{
	char ch = getchar(); ll x = 0, f = 1;
	while (ch<'0' || ch>'9') { if (ch == '-')f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
typedef pair<int, int> pir;
#define lson l,mid,root<<1
#define rson mid+1,r,root<<1|1
#define lrt root<<1
#define rrt root<<1|1
int T, n;
const int N = 3e3 + 10;
int a[N];
int dp[N][N];
int main() {
	T = read();
	while (T--) {
		n = read();
		upd(i, 1, n) {
			a[i] = read();
		}
		upd(i, 1, n) {
			upd(j, 1, n) {
				dp[i][j] = INF;
			}
		}
		upd(i, 1, n)dp[1][i] = 0;
		upd(i, 2, n) {
			int cnt = 0;
			dwd(j, i-1, 1) {
				if (a[j] + j >= i) {
					dp[i][a[j] + j] = min(dp[j][i - 1] + cnt, dp[i][a[j] + j]);
					cnt++;
				}
			}
			upd(j, i + 1, n) {
				dp[i][j] = min(dp[i][j], dp[i][j - 1]);
			}
		}
		printf("%d\n", dp[n][n]);
	}
	return 0;
}