For an array of size , we say that a pair is iff:
1 \le i < j \le m
\min(A_i,A_j) > 0
A_i > A_j
You're given an array of size .
For an integer (1 \le id \le n), we construct the array b_{id} by performing the following algorithm:
Initialize an array of size where all elements are .
Make c_{id} equal to a_1 (set c_{id} = a_1).
Initialize i=2.
Pick the maximum index 1 \le j \le n where c_j = 0, such that making c_j = a_i results in the array with the minimum number of pairs (Note that you need to minimize the number of pairs in the current array after setting c_j = a_i in the final array after the algorithm ends).
Make c_j equal to a_i (set c_j = a_i).
If i=n, end the algorithm, otherwise increase by and go back to step .
b_{id} is equal to the resulting array .
For each 1 \le id \le n, calculate the number of pairs in the array b_{id}.
The first line consists of a single integer (1 \le t \le 5 \cdot 10^5)the number of testcases.
The description of each testcase follows.
The first line of each testcase consists of a single integer (1 \le n \le 5 \cdot 10^5)the size of the array .
The second line contains integers a_1 , a_2 , ... , a_n (1 \le a_i \le n)the elements of the array .
It is guaranteed that the sum of over all testcases does not exceed 5 \cdot 10^5.
For each testcase, output the answer a sequence of space-separated integers.
Example 1
Let be the sum of over all testcases.
Subtask ( points): a_i \le a_{i-1} for all (1 < i \le n)
Subtask ( points): m \le 500
Subtask ( points): m \le 1000
Subtask ( points): m \le 5000
Subtask ( points): m \le 10^5
Subtask ( points): No additional constraints