#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

ll a[101000];
ll num[5010];
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      num[i] = 0;
      scanf("%lld", &a[i]);
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
      ans += max(0ll, a[i] - 1 - num[i]);
      num[i + 1] += max(0ll, (num[i] - a[i] + 1));
      for (int j = 2; j <= a[i] && j + i <= n; j++) num[j + i]++;
    }
    cout << ans << endl;
  }
}