#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<ll>
#define pb push_back
 
void  fun()
{
   ll n;cin>>n;
   ll a[n];
   ll zero=0;
   ll ans=0;
   for(ll i=0;i<n;i++)cin>>a[i];
   ll res=0;
   //for(ll i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
   res=a[0]-1;ans=res;
   vector<ll>v(n,0);
   if(res)v[0]=0;
   for(ll i=1;i<n;i++)
   {
       ll sum=0;
       for(ll j=0;j<=i-2;j++)
       {
               if(i-j<=a[j])sum++;
       }
      // cout<<i<<" "<<a[i]<<" "<<sum<<" "<<v[i-1]<<endl;
       sum=sum+v[i-1];
       v[i]=v[i-1];
       res=max(zero,a[i]-(sum+1));
       if(res)v[i]=0;
       else v[i]=sum-a[i]+1;
       ans=ans+res;
      // cout<<ans<<endl;
   }
   cout<<ans<<endl;
}
 
int main()
{
    ll z;cin>>z;
    while(z--)
    fun();
  return 0;
}