Count the Chaos

TarifEzaz, backbencher16 First Step Contest 2
Limits 1s, 512 MB

Imagine, you have an array of integers of size NN. At each index of this array is a unique integer from 1 to NN. You have to calculate how many pairs of indexes (i,j)(i, j) exists in the array such that:

  1. i<ji < j
  2. A[i]>A[j]A[i] > A[j]

Input

The first line contains a positive integer NN (1N1051 \le N \le 10^5), the size of the array.

The next NN lines have one number each, the content of the index i in the array.

Output

Output a single number, the result of this problem.

Sample

InputOutput
2
1
2
0

Submit

Login to submit.

Contributors

Statistics

61% Solution Ratio
RabeyaEarliest, Sep '19
LUMBERJACK_MANFastest, 0.0s
LUMBERJACK_MANLightest, 8.5 kB
rifat_246Shortest, 224B
Toph uses cookies. By continuing you agree to our Cookie Policy.