func_code_string: #include<bits/stdc++.h>   #define ll long long   #define R return   #define pb push_back   #define SI size()      using namespace std;      long long t,n,a[100030],ans,w[5030];      int main(){       cin >> t;       while(t--){           ans = 0;           memset(w,0,sizeof w);           cin >> n;           for(int i=0;i<n;i++)               cin >> a[i];           for(int i=0;i<n;i++){               if(a[i] - w[i] > 1)                   ans += a[i] - w[i] - 1;               if(a[i] - w[i] < 1)                   w[i+1] += 1 - a[i] + w[i];               if(a[i] > 1)                   for(int j=i+2;j<=min(i+a[i],n);j++) w[j]++;           }           cout << ans << endl;       }       return 0;   }      