Problem: Tenzing has balls arranged in a line. The color of the -th ball from the left is .
Tenzing can do the following operation any number of times:
- select and such that and ,
- remove from the array (and decrease the indices of all elements to the right of by ).
Tenzing wants to know the maximum number of balls he can remove.
Input Format: Each test contains multiple test cases. The first line of input contains a single integer () — the number of test cases. The description of test cases follows.
The first line contains a single integer () — the number of balls.
The second line contains integers () — the color of the balls.
It is guaranteed that sum of of all test cases will not exceed .
Output Format: For each test case, output the maximum number of balls Tenzing can remove.
Note: In the first example, Tenzing will choose and in the first operation so that . Then Tenzing will choose and again in the second operation so that . So Tenzing can remove balls in total.
In the second example, Tenzing will choose and in the first and only operation so that . So Tenzing can remove balls in total.