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


int main()
{
    ios::sync_with_stdio( false );
    cin.tie( nullptr ) ;
    cout.tie( nullptr ) ;

    int t;
    cin>>t;
    while( t-- )
    {
        ll n ;
        cin>>n;
        ll s[n] ;
        for(int i =0;i<n;i++)
        {
            cin>>s[i] ;
        }
        ll curr [ n ] ;
        memset( curr , 0 , sizeof( curr) );
        ll ans =0 ;
        for(int i =0;i<n;i++)
        {
            ll temp =  curr[i] ;
            if( temp < s[i] -1  ) {
                ans += s[i] - 1 - temp;
                temp += s[i] - 1 - temp;
            }
                if( i+1 < n )
                    curr[i+1] += temp - s[i] + 1 ;
                if( i+2 < n )
                for(int j = i+2 ;j< min( n , i + s[i] + 1) ; j++ )
                    curr[j] ++ ;

        }
        cout<<ans<<"\n";
    }
}