#include <iostream>
#include <list>
#include <algorithm>
#include <map>
#include <math.h>
#include <set>
#include <string>
#include <algorithm>
#include <cstdint>
#include <list>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
#include <ctype.h>
#include <queue>
#include <numeric>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <cstdlib>
#include <stack>
#include <ctime>
#define  lld  long long
#define newline cout << endl
#define pb push_back
#define flush cout.flush()
#define mp make_pair
lld shouldendl = 1;
#define se second
#define fi first
#define sfind(s,ele) (s).find((ele));
#define SPEED ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define starttime chrono::time_point<chrono::system_clock> start, end; start = chrono::system_clock::now()
#define showtime end = chrono::system_clock::now();  chrono::duration<double> elapsed_seconds = end - start; time_t end_time = chrono::system_clock::to_time_t(end); cout << "elapsed time: " << elapsed_seconds.cnt() << "s\n"
lld INF = (lld)(1e16+7);
lld MOD =  (lld)(1e9+7);
#define fileopen   freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout);
using namespace std;
lld modInverse(lld a ) {   lld m = MOD, m0 = m, y = 0, x = 1;  if (m == 1) return 0;   while (a > 1) {  lld q = a / m, t = m;  m = a % m, a = t, t = y;          y = x - q * y, x = t;   } if (x < 0)  x += m0; return x; }
lld add(long long a, long long b) {return ((a % MOD) + (b % MOD)) % MOD;}
lld mul(long long a, long long b) {return ((a % MOD) * (b % MOD)) % MOD;}
lld sub(long long a, long long b) {lld ans = ((a % MOD - b % MOD)) % MOD; if (ans < 0) ans += MOD; return ans;}
lld gcd(lld a, lld b) {if (b == 0) return a; return gcd(b, a % b);}
void MAIN(lld i, lld t);
int get(int f = 2) {if(f!=2) return 1; lld t; cin >> t; ; return t;}
template<class T> int logd(T name) {cout << name << endl; return 0;}
void test(int t) { for (lld i = 1; i <= t; i++) {MAIN(i, t); if (shouldendl) cout << "\n"; } }
lld power(lld x, lld y) { if(y==0) return 1; lld res = 1; x = x % MOD; if (x == 0) return 0;   while (y > 0) {   if (y & 1)      res = (res * x) % MOD; y = y >> 1; x = (x * x) % MOD;} return res; }
template <typename T, typename U> std::pair<T, U> operator+(const std::pair<T, U> & l, const std::pair<T, U> & r) {   return {l.first + r.first, l.second + r.second};                                    }
#define all(v) (v).begin(),(v).end()
lld popcnt(lld x) {return __builtin_popcountll(x);}
lld lcm(lld a, lld b) { return (a * b) / gcd(a, b);}
template<class T> bool input(vector<T> &v, lld n = -1) { if (n == -1) assert(v.size() != 0); if (n == -1) n = v.size();    for (auto &i : v) cin >> i; return 0;}
template<class T> bool print(vector<T> v, lld l = 0, lld r = -1) {  if (r == -1) r = v.size();   for (int i = l; i < r; i++) cout << v[i] << " "; return 0;}
//Observation, binary_search, dfs on strings, simplify the problem
//Observe and ELIMINATE, divide the problem

void MAIN(lld current_test_case, lld total_test_cases){
    lld n;
    cin >> n;
    vector<int> v(n);
    input(v);
    vector<int> temp(n+1,0);
    lld passes = 0;
    for(int i = 0;i<n;i++){
        int x = temp[i];
        if(x<v[i]){
            passes += v[i] - x - 1;
            x = v[i] - 1;
        }
        temp[i+1] += x - v[i]+1;
        if(i+2<n)
        for(int j = i+2;j<min(n,(lld)i+v[i]+1);j++)
            temp[j]++;

    }
    cout << passes;


}   

int main(){
  SPEED;

  shouldendl = 1;
  #ifndef ONLINE_JUDGE
    fileopen
  #endif
  //1-no test case
  test(get(2));
  return 0;
}


