#include <bits/stdc++.h>

#define fi first
#define se second
#define mp make_pair

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr double eps = 1e-8;
constexpr int NINF = 0xc0c0c0c0;
constexpr int INF = 0x3f3f3f3f;
constexpr ll mod = 1e9 + 7;
constexpr ll N = 3e3 + 5;

void solve(){
    int n;cin>>n;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++) cin>>a[i];
    vector<int> add(n+1);
    vector<vector<int> > f(n+1, vector<int> (n+2,n));
    f[n][n+1]=0;
    for(int i=n-1;i>=1;i--)
        for(int j=i+a[i];j>=i+1;j--)
            f[i][j]=min(f[i][j+1], f[j][i+a[i]+1]+add[j]++);
    cout<<f[1][2]<<'\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T;cin>>T;
    while(T--) solve();
    return 0;
}