There arenboxes lying in a line, and initiallyi-th box is at positioni. Little Alice wants to movei-th box to positionpi. She starts from position 1, and she can do the following operations:
Only the first operation takes one minute and Alice can carry at most one box at any time. So, find the minimum time needed for Alice to move all the boxes and go back to position 1.
There are multiple test cases. The first line of input contains an integerTindicating the number of test cases. For each test case:
The first line contains an integern(1 ≤n≤ 200000) denoting the number of boxes.
The next line containsnintegersp1,p2, ...,pn(1 ≤pi≤n). Note, {p1,p2, ...,pn} is a permutation of {1, 2, ...,n}.The sum of values ofnin all test cases doesn't exceed 4000000.
2
3
1 2 3
3
3 1 2
0
4