[ABC190F] 循环移位与逆序对 (Shift and Inversions)
Score : points
Problem Statement
Given is a sequence that is a permutation of .
For each , find the inversion number of the sequence defined as .
What is inversion number? The inversion number of a sequence is the number of pairs of indices such that .
Constraints
-
All values in input are integers.
-
-
is a permutation of .
Input
Input is given from Standard Input in the following format:
$N$
$a_0$ $a_1$ $a_2$ $\cdots$ $a_{N-1}$
Output
Print lines.
The -th line should contain the answer for the case .
Sample Input 1
4
0 1 2 3
Sample Output 1
0
3
4
3
We have .
For , the inversion number of is .
For , the inversion number of is .
For , the inversion number of is .
For , the inversion number of is .
Sample Input 2
10
0 3 1 5 4 2 9 6 8 7
Sample Output 2
9
18
21
28
27
28
33
24
21
14