#include <bits/stdc++.h>

using namespace std;

int n, dp[3002][3002], t, a[3002];

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    int i, j;
    for (i = 1; i <= n; i++)
      cin >> a[i];
    for (i = 1; i <= n; i++)
      for (j = 0; j <= n; j++)
        dp[i][j]  = 1e9;
    dp[1][0] = 0;
    for (i = 0; i <= n; i++)
      dp[1][i] = 0;
    for (i = 2; i <= n; i++) {
      int cnt = 0;
      for (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);
          cnt++;
        }
      }
      for (int j = 1; j <= n; j++)
        dp[i][j] = min(dp[i][j], dp[i][j - 1]);
    }
    cout << dp[n][n] << "\n";
  }
  return 0;
}
