#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define pb push_back
#define pii pair<int, int>
#define chmin(x, v) x = min(x, v)
#define chmax(x, v) x = max(x, v)
#define int long long
using namespace std;
 
const int N = 1e6 + 1;
 
signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);

  int t; cin >> t;
  while (t--){
    int nVals; cin >> nVals;
    vector<int> vals(nVals);
    vector<int> vraiTruc(nVals);
    for (int& val : vals)
      cin >> val;

    int last1 = nVals;
    for (int ind = nVals - 1; ind >= 0; --ind){
      if (vals[ind] != 1)
        last1 = ind;
      vraiTruc[ind] = last1;
    }

    int nb = 0;
    for (int ind = 0; ind < nVals; ++ind){
      last1 = nVals;
        for (int ind = nVals - 1; ind >= 0; --ind){
          if (vals[ind] != 1)
           last1 = ind;
         vraiTruc[ind] = last1;
        }

      if (vals[ind] + ind >= nVals){
        nb += vals[ind] - (nVals - ind);
        vals[ind] = nVals - ind;
      }

      while (vals[ind] != 1){
      /*  cout << "wsh\n";
        for (int& val : vals)
          cout << val << " ";
        cout << endl;*/

        int noeud = ind;
        ++nb;
        while (noeud < nVals){
          int before = vals[noeud];
          vals[noeud] = max(1ll, vals[noeud] - 1);;
          noeud += before;
          if (noeud < nVals)
            noeud = vraiTruc[noeud];
        }

      }
    }
    cout << nb << endl;
  }
}