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

#define ll long long

int main(){
	int t = 1;
	cin >> t;
	while(t--){
		int n;
		cin >> n;
		vector<int> s(n),e(n);
		for(int &x:s){
			cin >> x;
		}
		ll ans = 0;
		for(int i = 0; i < n; i++){
			int ops = max(s[i] - 1,0);
			ans += max(0,ops - e[i]);
			for(int j = i + 2; j < min(n,i+ops+2); j++){
				e[j]++;
			}
			if(i+1 < n) e[i+1] += max(0,e[i]-ops);
		}
		cout << ans << "\n";
	}
	return 0;
}