Chef has a sequence of
integers . He can perform the following operation any number of times (possibly, zero):
- Choose any positive integer and insert it at any position of the sequence (possibly the beginning or end of the sequence, or in between any two elements).
For example, if and Chef selects , then after the operation he can obtain one of the sequences , or .
Chef wants this sequence to satisfy the following condition: for each , . Here, denotes the length of .
Help Chef to find the minimum number of operations that he has to perform to achieve this goal. It can be proved that under the constraints of the problem, it's always possible to achieve this goal in a finite number of operations.
Input Format
- The first line of input contains an integer , denoting the number of test cases. The description of test cases follows.
- The first line of each test case contains an integer .
- The second line contains space-separated integers .
Output Format
For each test case, print a single line containing one integer — the minimum number of operations that Chef has to perform to achieve the given condition.
Constraints
- Sum of over all test caes does not exceed .
Subtasks
Subtask #1 (100 points): Original constraints
Sample Input 1
3
3
2 4 5
3
4 1 3
4
3 2 4 2
Sample Output 1
0
1
2
Explanation
Test case : The given sequence does not contain any index such that . Hence Chef does not have to perform any operation.
Test case : In the given sequence, . Chef can choose and insert it before the first element, making the sequence , which does not contain any index for which .
Test case : In the given sequence, . Chef can perform the following sequence of operations:
- Choose and insert it before the first element. The sequence becomes , and now .
- Choose and insert it between the third and fourth element. The sequence becomes , which does not contain any index for which .
It can be verified that there is no way to satisfy the given condition in less than two operations.
ConversionConversion EmoticonEmoticon