#ds103. 逆序对2
逆序对2
Inversion Pairs 2
Problem Description
You are given numbers . For two numbers in the array, if appears before and , then is called an inversion pair of the array . How many inversion pairs are there in total? Formally, count the number of pairs such that and .
Input Format
The first line contains an integer .
The next line contains integers .
Output Format
Output one number on a single line, the answer.
Sample Input
4
4 2 3 1
Sample Output
5
Sample Explanation
The 5 inversion pairs are .
Constraints
For of the data, , , and each number appears exactly once.