/* dont stick to an approach */
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>
#include <numeric>
#include <cstdlib>

typedef long long ll;
typedef unsigned long long int ull;
typedef long double ldb;

#define PB push_back

#define For(i, n) for (ll i = 0; i < n; i++)

#define PYES cout<<"YES\n"
#define PNO cout<<"NO\n"
#define PYes cout<<"Yes\n"
#define PNo cout<<"No\n"

#define Fas ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

const int M= 1e9 +7;


using namespace std;

//--------------------------------------------functions-------------------------------------------------//

ll power(ll a,ll b){int result=1;while(b>0){if(b%2 == 1){result *= a;} a *= a;b /= 2;}return result;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
ll countSetBits(ll x){ll Count=0;while(x>0){if(x&1) Count++;x=x>>1;}return Count;}
bool isPerfectSquare(ll n){ll sr = sqrt(n);if (sr * sr == n)return true;else return false;}
ll mod(ll x){return ((x%M + M)%M);}
ll add(ll a, ll b){return mod(mod(a)+mod(b));}
ll mul(ll a, ll b){return mod(mod(a)*mod(b));}
ll powerM(ll a,ll b){ll res=1;while(b){if(b%2==1){res=mul(a,res);}a=mul(a,a);b/=2;}return res;}
//------------------------------------sieve of erantothenes-----------------------------------------------//

vector<bool> sieve_of_eratothenes(ll n){
    vector<bool> a(n+1,1);
    a[0]=0;
    a[1]=0;
    for(ll i=2;i<=sqrt(n);i++){
        if(a[i]==1){
            for(ll j=2;i*j<=n;j++){
                a[j*i]=0;
            }
        }
    }
    return a;
}
//----------------------------------------nCr mod------------------------------------------------------//
ll modInverse(ll n){
    return powerM(n,M-2);
}
ll nCrM(ll n,ll r){
    if(n<r) return 0;
    if(r==0) return 1;
    vector<ll> fact(n+1);
    fact[0]=1;
    for(ll i=1;i<=n;i++){
        fact[i]=mul(fact[i-1],i);
    }
    return mul(mul(fact[n],modInverse(fact[r])),modInverse(fact[n-r]));
}
//-----------------------------------------------solve-----------------------------------------------------//

void solve(){
    ll n,count=0;cin>>n;
    vector<ll> v(n);
    vector<ll> m(n);
    for(ll i=0;i<n;i++){
        cin>>v[i];
    }
    for(ll i=0;i<n-2;i++){
        if(i+2<n) m[i+2]++;
        if(i+v[i]+1<n) m[i+v[i]+1]--;
    }
    for(auto it=m.begin();it!=m.end();it++){
        if(it!=m.begin()){
            it--;
            ll a=*it;
            it++;
            *it+=a;
        }
    }
    for(ll i=0;i<n-1;i++){
        if(m[i]>=v[i]){
            m[i+1]+=(m[i]-v[i]+1);
        }else{
            count+=(v[i]-1-m[i]);
        }
    }
    if(v[n-1]>m[n-1]){
        count+=(v[n-1]-1-m[n-1]);
    }
    cout<<count<<endl;
}

int main(){
    Fas;

    ll t=0;
    cin>>t;
    while(t--)
        solve();

    return 0;
}