Statement : Right Maximum
You are given an array $a$ of $n$ integers.
While the array is not empty, an operation is performed:
- The maximum element in the array is chosen (if there are multiple, the rightmost maximum is chosen).
- All elements at or after the chosen element are removed from the array.
Your task is to calculate how many operations are performed before the array becomes empty.
The first line contains one integer $t$ ($1 \le t \le 10^4$) — the number of test cases.
Each test case consists of two lines:
- The first line contains one integer $n$ ($2 \le n \le 2 \cdot 10^5$).
- The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le n$).
The sum of $n$ over all test cases does not exceed $2 \cdot 10^5$.
For each test case, print one integer — the number of operations performed.
Input
4
5
2 1 2 3 1
6
1 2 3 4 5 6
3
3 2 1
4
1 3 3 1
Output
3
6
1
3
Note
In the first example, array is $[2, 1, 2, 3, 1]$. First operation: rightmost max is at index 4 (value 3), remove from index 4 → $[2, 1, 2]$. Second: rightmost max at index 2 (value 2), remove from 2 → $[2, 1]$. Third: rightmost max at index 0, remove all → empty. So 3 operations.