#abc190f. [abc190_f]Shift and Inversions
[abc190_f]Shift and Inversions
Problem Statement
Given is a sequence A = \[a_0, a_1, a_2, \\dots, a_{N-1}\] that is a permutation of .
For each , find the inversion number of the sequence B = \[b_0, b_1, b_2, \\dots, b_{N-1}\] defined as .
What is inversion number? The inversion number of a sequence A = \[a_0, a_1, a_2, \\dots, a_{N-1}\] is the number of pairs of indices such that and .
Constraints
- All values in input are integers.
- is a permutation of .
Input
Input is given from Standard Input in the following format:
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 A = \[0, 1, 2, 3\].
For , the inversion number of B = \[0, 1, 2, 3\] is .
For , the inversion number of B = \[1, 2, 3, 0\] is .
For , the inversion number of B = \[2, 3, 0, 1\] is .
For , the inversion number of B = \[3, 0, 1, 2\] 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