eolymp
bolt
Try our new interface for solving problems
Problems

Number of inversions

Number of inversions

Write a program that finds for a given array A = <a1, a2, ..., an> the number of such pairs (i, j) that i < j and ai > aj.

Input

The first line contains the number of array elements n (1n50000). Second line contains n different elements of array A - nonnegative integers, not greater than 106.

Output

Print the number of required pairs.

Time limit 1 second
Memory limit 128 MiB
Input example #1
5
6 11 18 28 31
Output example #1
0
Input example #2
6
4 7 3 5 2 1
Output example #2
12