~/algor $ cat problems/saralash-inversiyalar
Number of inversions
Medium
1000 ms
128 MB
53%
$n$ integers $a_{1}, a_{2}, \ldots, a_{n}$ are given. How many pairs (inversions) are there with $i \lt j$ and $a_{i} \gt a_{j}$?
Input
The first line contains a positive integer $n$. The second line contains $n$ integers $a_{i}$ separated by spaces.
Output
One integer — the number of inversions.
Note
$1 \le n \le 10^{5}$
$-10^{9} \le a_{i} \le 10^{9}$
Examples
Input #1
5 2 4 1 3 5
Output #1
3
Input #2
1 10
Output #2
0