#include <iostream>

constexpr int N = 3005;

int T, n;
int a[N], f[N][N];

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