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

#define int long long 
#define G vector<vector<int>>
//~vector<int> arr(100005);

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;cin >> t;
	while(t--){
		int n; cin >> n;
		vector<int> arr(n), hits(n, 0);
		for(int i = 0; i < n; i++)
			cin >> arr[i];
		int ans = 0;
		for(int i = 0; i < n; i++){
			if(arr[i] == 1 and hits[i] == 0)
				continue;
				
			ans += max((int)1, arr[i] - hits[i]) - 1;
			for(int j = i + 2; j <= i + arr[i] && j < n; j++)
			{
				hits[j] += 1;
				}
			if(i == n-1)
				continue;
			for(int j = 1; j<= hits[i] - arr[i] + 1; j++)
				hits[i+1]++;
			
			}
		cout << ans << endl;
	}
	return 0;
}
