#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define int ll
#define endl '\n'
#define yes cout << "YES" << endl
#define no cout << "NO" << endl

#ifdef ROHIT_SYS
#include "headers/debug.hpp"
#endif

 
int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	#ifdef ROHIT_SYS
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif

	int t;
	cin >> t;
	while(t--) {
		int n, passes = 0;
		cin >> n;

		vector<int> s(n), pekos(n, 0);
		for(auto &x : s) cin >> x;

		for(int i = 0; i < n; i++) {
			int cur_pek = pekos[i];

			if(cur_pek < s[i]-1) {
				passes += s[i]-1-cur_pek;
				cur_pek += s[i]-1-cur_pek;
			}

			if(i+1 < n) pekos[i+1] += cur_pek-s[i]+1;
			if(i+2 < n) {
				for(int x = i+2; x < min(n, i+1+s[i]); x++) {
					pekos[x]++;
				}
			}
		}

		cout << passes << endl;
	}
 
	return 0;
}


