// Problem: C. Pekora and Trampoline
// Contest: Codeforces - Codeforces Global Round 13
// URL: https://codeforces.ml/contest/1491/problem/C
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// Date: 2021-03-01 12:29:37
// --------by Herio--------

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull; 
const int N=5e3+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define PII pair<int,int>
#define fi first
#define se second
#define pb emplace_back 
void Print(int *a,int n){
	for(int i=1;i<n;i++)
		printf("%d ",a[i]);
	printf("%d\n",a[n]); 
}
int T,n,a[N];
ll ans,t[N];
int main(){
	scanf("%d",&T);while(T--){
		scanf("%d",&n);
		for(int i=0;i<n;i++) scanf("%d",&a[i]),t[i]=0;ans=0;
		for(int i=0;i<n;i++){
			ll x=t[i];
			ll tot=a[i]-1;
			if(x<tot){
				ans+=tot-x;
				x=tot;
			}
			t[i+1]+=x-tot;
			for(int j=i+2;j<min(n,i+a[i]+1);j++) t[j]++;
		}
		printf("%lld\n",ans);
	}
	return 0;
}
