There is a trampoline park with n trampolines in a line. The i-th of which has strength S_i.

Pekora can jump on trampolines in multiple passes. She starts the pass by jumping on any trampoline of her choice. 

If at the moment Pekora jumps on trampoline i, the trampoline will launch her to position i + S_i, and S_i will become equal to max(S_i-1,1). In other words, S_i will decrease by 1, except of the case S_i=1, when S_i will remain equal to 1. 

If there is no trampoline in position i + S_i, then this pass is over. Otherwise, Pekora will continue the pass by jumping from the trampoline at position i + S_i by the same rule as above.

Pekora can't stop jumping during the pass until she lands at the position larger than n (in which there is no trampoline). Poor Pekora!

Pekora is a naughty rabbit and wants to ruin the trampoline park by reducing all S_i to 1. What is the minimum number of passes she needs to reduce all S_i to 1?

Input

The first line contains a single integer t (1 ≤ t ≤ 500) — the number of test cases.

The first line of each test case contains a single integer n (1 ≤ n ≤ 5000) — the number of trampolines.

The second line of each test case contains n integers S_1, S_2, ..., S_n (1 ≤ S_i ≤ 10^9), where S_i is the strength of the i-th trampoline.

It's guaranteed that the sum of n over all test cases doesn't exceed 5000.

Output

For each test case, output a single integer — the minimum number of passes Pekora needs to do to reduce all S_i to 1.

Example

Input


3
7
1 4 2 2 2 2 2
2
2 3
5
1 1 1 1 1


Output


4
3
0

Note

For the first test case, here is an optimal series of passes Pekora can take. (The bolded numbers are the positions that Pekora jumps into during these passes.)

  * [1,4,2,2,2,2,2] 
  * [1,4,1,2,1,2,1] 
  * [1,3,1,2,1,1,1] 
  * [1,2,1,2,1,1,1] 



For the second test case, the optimal series of passes is show below.

  * [2,3] 
  * [1,3] 
  * [1,2] 



For the third test case, all S_i are already equal to 1.

import java.util.*;
import java.io.*;

public class three {

	public static void main(String[] args) throws IOException, FileNotFoundException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader in = new BufferedReader(new FileReader("three"));

		int t = Integer.parseInt(in.readLine());
		while (t-- > 0) {
			int n = Integer.parseInt(in.readLine());
			long[] arr = new long[n];
			StringTokenizer st = new StringTokenizer(in.readLine());
			for (int i=0; i<n; i++) {
				arr[i] = Integer.parseInt(st.nextToken());
			}
			
			int notone=0;
			long ans=0;
			for (int i=0; i<n; i++) {
				long val = Math.max(n-i, Math.max(i*(i+1)/2, 1));
				if (arr[i] > val ) {
					ans += (arr[i] - val);
					arr[i] = val;
				}
				if (arr[i] != 1) notone++;
			}
			
//			while (notone > 0) {				
//				int index=0;
//				ans++;				
//				while (index < n) {
//					long prev = arr[index];
//					arr[index] = Math.max(arr[index]-1, 1);
//					if (arr[index] == 1 && prev != 1) notone--;
//					index += (prev);
//				}
//			}
			
//			long psum=0;
//			for (int i=0; i<n; i++) {
//				if (arr[i] > 1) {
//					if (arr[i]-1 <= psum) {
//						arr[i] = 1;
//					}
//					else {
//						arr[i] -= psum;
//						ans += (arr[i] - 1);
//						psum += (arr[i] - 1);
//						arr[i] = 1;
//					}
//				}
//			}
			
			SegTree s = new SegTree(n);
			for (int i=0; i<n; i++) {
				long rem = s.comp_index(i);
				if (Math.min(n, (int)(i+arr[i]))+1 > i+2) {
					s.modify(i+2, Math.min(n, (int)(i+arr[i]))+1, 1);
				}
				if (arr[i] == 1) {
					if (i+1 < n) s.modify(i+1, i+2, rem);
				}
				else if (rem > arr[i]-1) {
					long left = rem - (arr[i] - 1);
					if (i+1 < n) s.modify(i+1, i+2, left);
				}
				arr[i] = Math.max(1, arr[i] - rem);
				ans += (arr[i] - 1);
//					if (arr[i]>=2) {
//						s.modify(i+1, Math.min(n-1, (int)(i+arr[i])), 1);
//					}
				arr[i] = 1;
			}
			
			System.out.println(ans);	
		}
	}
	
	static class SegTree {
		int size=1;
		long[] tree;
		
		public SegTree(int n) {			
			while (size < n) size *= 2;
			tree = new long[2*size];
		}
		
		// random computation on index
		public long comp_index(int i) { return comp_index(i, 0, 0, size); }
		
		public long comp_index(int i, int x, int lx, int rx) {
			if (rx - lx == 1) return tree[x];	// in leaf node aka bottom level
			// propogate(x, lx, rx);
			int m = (lx + rx)/2;	long result = 0;
			if (i < m) result = comp_index(i, 2*x+1, lx, m);	// go to left subtree
			else result = comp_index(i, 2*x+2, m, rx);		// go to right subtree
			return result + tree[x];
		}
				
		// change segments (l to r-1)
		public void modify(int l, int r, long v) { modify(l, r, v, 0, 0, size); }
		
		public void modify(int l, int r, long v, int x, int lx, int rx) {
			if (lx >= r || rx <= l) return;		// do not intersect this segment
			// propogate(x, lx, rx);
			if (l <= lx && rx <= r) {		// inside whole segment
				tree[x] += v;
				return;
			}
			int m = (lx + rx)/2;
			modify(l, r, v, 2*x+1, lx, m);	modify(l, r, v, 2*x+2, m, rx);
		}
		
		static long NONE = (long)(1e18);	// use a value that will never be used
				// if all values can be used, use a boolean array to see if tree[x]
				// has a value stored or not
		public void propogate(int x, int lx, int rx) {
			if (rx - lx == 1) return;		// leaf
			if (tree[x] != NONE) {
				tree[2*x+1] = tree[x];	tree[2*x+2] = tree[x];
				tree[x] = NONE;
			}
		}
		
		public void print() {
			System.out.println(Arrays.toString(tree));
			System.out.println();
		}
	}
}