#include <bits/stdc++.h>

using namespace std;

int f[3005][3005];
int n, a[20005];
int main( ) {
	int T;
	scanf("%d", &T);
	while (T --) {
		scanf("%d", &n);
		for (int i = 1; i <= n; i ++) {
			scanf("%d", &a[i]);
			a[i] = min(a[i], n - i);
		}
		memset(f, 0x3f, sizeof(f));
		for (int i = 1; i <= n; i ++) f[1][i] = 0;
		for (int i = 2; i <= n; i ++) {
			int tmp = 0;
			for (int j = i - 1; j >= 1; j --)
				if (j + a[j] >= i) {
					f[i][j + a[j]] = min(f[i][j + a[j]], f[j][i - 1] + tmp);
					++ tmp;
				}
			for (int j = i; j < n; j ++)
				f[i][j + 1] = min(f[i][j + 1], f[i][j]);
		}
		printf("%d\n", f[n][n]);
	}
	return 0;
}
