How many inversions?

Count the number of inversions of every given sequence of n integer
numbers x₁…x_(n). Remember that an inversion is a pair of indices i and
j such that 1 ≤ i < j ≤ n and x_(i) > x_(j).

Input

Input consists of several cases, each one with n followed by the n
integer numbers x₁…x_(n). Assume 0 ≤ n ≤ 50000.

Output

For every case, print the number of inversions of the sequence.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T11:50:34.216Z

© Jutge.org, 2006–2026.
https://jutge.org
