#include <bits/stdc++.h>
using namespace std;
int t, a[3001], f[3001][3001];
int main() {
 cin >> t;
 while(t--) {
  int n; cin >> n;
  // memset(f, 0, sizeof(f));
  for(int i=1;i<=n;++i) cin >> a[i];
  for(int i=2;i<=n;++i) {
   for(int j=1;j<=n;++j) f[i][j] = 3000;
   int cnt = 0;
   for(int j=i-1;j>0;--j) {
    if(j+a[j] >= i) f[i][j+a[j]] = min(f[i][j+a[j]], f[j][i-1] + cnt), ++cnt;
   }
   for(int j=i+1;j<=n;++j) f[i][j] = min(f[i][j], f[i][j-1]);
  }
  cout << f[n][n] << endl;
 }
 return 0;
}