문제
Tired of his stubborn cowlick, Farmer John decides to get a haircut. He has
For each of
(Fun fact: the average human head does indeed have about
SCORING:
Test case 2 satisfies
N\le 100. Test cases 3-5 satisfy
N\le 5000. Test cases 6-13 satisfy no additional constraints.
Problem credits: Dhruv Rohatgi
입력
The first line contains
The second line contains
출력
For each of
Note that the large size of integers involved in this problem may require the use of 64-bit integer data types (e.g., a "long long" in C/C++).
예제1
5
5 2 3 3 0
0
4
4
5
7
The fourth line of output describes the number of inversions when FJ's hairs are decreased to length 3. Then