#P1987C. Basil's Garden

Basil's Garden

Description

There are nn flowers in a row, the ii-th of them initially has a positive height of hih_i meters.

Every second, the wind will blow from the left, causing the height of some flowers to decrease.

Specifically, every second, for each ii from 11 to nn, in this order, the following happens:

  • If i=ni = n or hi>hi+1h_i > h_{i + 1}, the value of hih_i changes to max(0,hi1)\max(0, h_i - 1).

How many seconds will pass before hi=0h_i=0 for all 1in1 \le i \le n for the first time?

Each test contains multiple test cases. The first line of input contains a single integer tt (1t1041 \le t \le 10^4) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer nn (1n1051 \le n \le 10^5) — the number of flowers.

The second line of each test case contains nn integers h1,h2,,hnh_1, h_2, \ldots, h_n (1hi1091 \le h_i \le 10 ^ 9) — the heights of the flowers.

It is guaranteed that the sum of nn over all test cases does not exceed 10510^5.

For each test case, output a single integer — the number of seconds that will pass before hi=0h_i=0 for all 1in1 \le i \le n.

Input

Each test contains multiple test cases. The first line of input contains a single integer tt (1t1041 \le t \le 10^4) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer nn (1n1051 \le n \le 10^5) — the number of flowers.

The second line of each test case contains nn integers h1,h2,,hnh_1, h_2, \ldots, h_n (1hi1091 \le h_i \le 10 ^ 9) — the heights of the flowers.

It is guaranteed that the sum of nn over all test cases does not exceed 10510^5.

Output

For each test case, output a single integer — the number of seconds that will pass before hi=0h_i=0 for all 1in1 \le i \le n.

Sample Input 1

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

Sample Output 1

4
3
9
7

Note

In the first test case, the flower heights change as follows: [1,1,2][1,1,1][1,1,0][1,0,0][0,0,0][1, 1, 2] \rightarrow [1, 1, 1] \rightarrow [1, 1, 0] \rightarrow [1, 0, 0] \rightarrow [0, 0, 0].

In the second test case, the flower heights change as follows: [3,1][2,0][1,0][0,0][3, 1] \rightarrow [2, 0] \rightarrow [1, 0] \rightarrow [0, 0].