#include <bits/stdc++.h>

using namespace std;

#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define mp make_pair
#define ALL(x) x.begin(), x.end()

typedef long long ll;
// const double PI = 4*atan(1.);
const int INF = 0x3f3f3f3f;
const int maxn = 3005;

int a[maxn];
int dp[maxn][maxn];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        for (int i = 1; i <= n; ++i) cin >> a[i]; 
        for (int i = 1; i <= n; ++i)    for (int j = 1; j <= n; ++j)    dp[i][j] = INF;
        dp[1][1] = 0;
        for (int i = 1; i <= n; ++i) {
            int cnt = 0;
            for (int j = i - 1; j >= 1; --j) {
                if (j + a[j] >= i)
                    dp[i][j + a[j]] = min(dp[i][j + a[j]], dp[j][i - 1] + cnt++);
            }
            for (int j = i + 1; j <= n; ++j)
                dp[i][j] = min(dp[i][j], dp[i][j - 1]);
        }
        cout << dp[n][n] << '\n';
    }
    return 0;
}