14592 - Inversion Count   

Description

Given an array of size $N$, find the inversion count in the array. Two array elements $arr[i]$ and $arr[j]$ form an inversion if $arr[i] > arr[j]$ and $i < j$.

Input

The first line contains an integer $N$, represents the size of the array.

The following one line contains $N$ integers, represent the elements in the array.

Contraints

  • $1 \le N, arr[i] \le 5*10^5$

Subtask

  1. (Testcases 1-5) $1 \le N \le 10^3$
  2. (Testcases 6-10) No additional constraints.

Output

Output the number of inversions. You should not output a new line ('\n') after your answer.

Sample Input  Download

Sample Output  Download

Tags




Discuss