#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <ctime>
#include <vector>
#define ls id<<1
#define rs id<<1|1
//#define mid (l+r>>1)
#define Mid (L+R>>1)
#define ll long long
//#define Vector Point
#define mul(a,b) (1ll*(a)*(b)%mod)
const int N=200010;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int mod=1000000007;
const double pi=acos(-1);
const double eps=1e-7;
template <class T>
void read(T &x)
{
	x=0;int f=0;char c=getchar();
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-'0',c=getchar();
	if(f) x=-x;
}
template <class T>
T plus(T a,T b){return a+b>=mod?a+b-mod:a+b;}
template <class T>
T Abs(T x){return x>0?x:-x;}
template <class T> 
inline void ckmax(T &x,T y){x=x>y?x:y;}
template <class T> 
void ckmin(T &x,T y){x=x<y?x:y;}
template <class T>
T GCD(T a,T b){return b?GCD(b,a%b):a;}
int qp(int a,int b){int r=1;for(;b;a=mul(a,a),b>>=1) if(b&1) r=mul(r,a);return r;}
int n,a[5010],d[5010];
//char s[N];
void work()
{
	ll ans=0;
	read(n);
	for(int i=1;i<=n;i++) d[i]=0;
	for(int i=1;i<=n;i++)
	{
		read(a[i]);
		for(int j=2;j<=a[i]&&i+j<=n;j++)
			++d[i+j];
		a[i]-=d[i];
		if(a[i]<=0) d[i+1]+=1-a[i];
		//printf("d: %d\n",d[i]);
		ans+=std::max(0,a[i]-1);
	}
	printf("%lld\n",ans);
}
int main()
{
	int T=1;
	read(T);
	//scanf("%d",&T);
	while(T--) work();
	return 0;
}