#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin>>t;
    while(t--)
    {
        ll n,ans=0;
        cin>>n;
        vector<ll>a(n+5),curr(n+5,0);
        for(ll i=1;i<=n;i++)
        cin>>a[i];
        for(ll i=1;i<=n;i++)
        {
            ll temp=curr[i];
            if(temp<a[i]-1)
            {
                ans+=(a[i]-1-temp);
                temp+=(a[i]-1-temp);
            }
            curr[i+1]+=(temp-a[i]+1);
            for(ll j=min(n,i+a[i]);j>i+1;j--)
            curr[j]++;
        }
        cout<<ans<<endl;
    }
    return 0;
}