14347 - 2024_DS_Summer_Assignment1_pC   

Description

Given an array with length n a1, a2, ... , an. Answer the number of pairs (i, j) satisfying:

  • 1 <= i < j <= n
  • ai > aj

Input

The first line contains one integer n, the length of array. 

The next line contains n integers a1, a2, ... , an.

Constrain

  • 1 <= n <= 106
  • | ai | <= 1016, i = 1, 2, ... , n

Output

Output one integer, the number of pairs that satisfy the condition above.

Remember to print a ‘\n’ at the end of the output.

Sample Input  Download

Sample Output  Download

Tags




Discuss