#include <bits/stdc++.h>


void solve(int case_num) {
    // Code here
    int n;
    std::cin >> n;
    std::vector<int> S(n);
    std::vector<int> skip(n);
    std::iota(skip.begin(), skip.end(), 1);

    for (int i = 0; i < n; i++) {
        std::cin >> S[i];
    }

    long long sol = 0;

    for (int i = 0; i < n; i++) {
        if (S[i] == 1) {
            continue;
        }

        if (i == n - 1) {
            sol += S[i] - 1;
            break;
        }

        if (i + S[i] >= n) {
            sol += S[i] - (n - 1 - i);
            S[i] = n - 1 - i;
        }

        while (S[i] > 1) {
            int j = i;
            while (j < n) {
                int s = S[j];
                if (s == 1) {
                    j = skip[j];
                    continue;
                }
                S[j] = std::max(S[j] - 1, 1);
                j += s;
            }
            sol++;
        }

        for (int j = n - 2; j >= 0; j--) {
            if (S[j] == 1 && S[j + 1] == 1) {
                skip[j] = skip[j + 1];
            }
        }
    }
    std::cout << sol << "\n";
}


int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int num_cases;
    std::cin >> num_cases;

    for (int case_num = 1; case_num <= num_cases; case_num++) {
        solve(case_num);
    }
}