#include <bits/stdc++.h>
#define MOD 100000000
typedef long long int ll;
typedef unsigned long long int ull;
#define INF 100000000000
#define qq cout<<'\n';
#define zz cout<<" ";
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define loop(i,a,b) for(int i=a;i<b;i++)
using namespace std;

void solve() {
ll ans=0;
int n;
cin>>n;
ll arr[n];
ll car[n];
for(int i=0;i<n;i++) {
    cin>>arr[i];
    car[i]=0;
}
for(ll i=0;i<n;i++) {
    for(ll j=i+2;j<=i+arr[i]&&j<n;j++) {
        car[j]++;
    }
    if(i<n-1&&car[i]>=arr[i])
    car[i+1]+=(car[i]-arr[i]+1);
    arr[i]=max(arr[i]-car[i],1ll);
    ans+=(arr[i]-1);
}
cout<<ans;qq
}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t=1;
cin>>t;
while(t--) {
  solve();
}
return 0;
}