#K94112. Moves to Bring Highest Scored Book to the Front

    ID: 38570 Type: Default 1000ms 256MiB

Moves to Bring Highest Scored Book to the Front

Moves to Bring Highest Scored Book to the Front

You are given several test cases. In each test case, there is a row of books, each with a popularity score. Your task is to determine the minimum number of moves required to bring the book with the highest score to the front of the row.

In one move, you are allowed to swap the highest scored book with the book immediately to its left. Since only adjacent swaps are permitted, the total number of moves required is equal to the current index (0-indexed) of the first occurrence of the maximum element. In other words, if the highest scored book is at index i, then the number of moves required is:

moves=i\text{moves} = i

Note that if the maximum score occurs multiple times, consider the first occurrence (i.e. the one with the smallest index).

inputFormat

The input is read from standard input (stdin) and has the following format:

T
n₁
a₁ a₂ ... aₙ₁
n₂
b₁ b₂ ... bₙ₂
...
n_T
c₁ c₂ ... cₙₜ

Here, T is the number of test cases. For each test case, the first line contains an integer n representing the number of books. The next line contains n space-separated integers which denote the popularity scores of the books.

outputFormat

For each test case, output a single integer on a new line representing the number of moves required to bring the highest scored book to the front of the row. The output should be written to standard output (stdout).

## sample
1
5
1 3 2 5 4
3

</p>