#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <map>
#include <deque>
#include <iomanip>
#include <functional>
#include <unordered_set>
#include <queue>

using namespace std;
typedef long long ll;
typedef long double ld;

void solve()
{
	int n;
	cin >> n;
	vector <int> a(n + 1);

	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i];
		a[i] = min(a[i], n - i);
	}

	vector <vector <int>> cost(n + 2, vector <int>(n + 2, 1e9));
	vector <vector <int>> suff(n + 2, vector <int>(n + 2, 1e9));
	vector <vector <int>> cant(n + 2, vector <int>(n + 2, 1e9));

	for (int j = n; j > 1; --j)
	{
		cant[j][j] = 0;
		for (int i = j - 1; i >= 1; --i)
		{
			cant[i][j] = cant[i + 1][j];
			if (i + a[i] >= j)
			{
				cant[i][j]++;
			}
		}
	}

	cost[n][n + 1] = 0;
	suff[n][n + 1] = 0;

	for (int i = n - 1; i >= 1; --i)
	{
		for (int j = i + 1; j <= a[i] + i; ++j)
		{
			cost[i][j] = cant[i + 1][j] + suff[j][i + a[i] + 1];
		}
		for (int j = n; j >= 1; --j)
		{
			suff[i][j] = min(cost[i][j], suff[i][j + 1]);
		}
	}

	int ans = 1e9;

	for (int i = 2; i <= n; ++i)
	{
		ans = min(ans, cost[1][i]);
	}

	cout << ans << '\n';
}


signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	int t;
	cin >> t;
	while (t--) solve();
	return 0;
}
