#K68072. Count Inversions
Count Inversions
Count Inversions
In this problem, you are given a list of integers. Your task is to count the number of inversions in the list. An inversion is defined as a pair of indices \( (i, j) \) such that \( i a_j \).
For example, in the list [2, 3, 8, 6, 1], the inversions are: \( (2,1) \), \( (3,1) \), \( (8,6) \), \( (8,1) \), and \( (6,1) \). Thus, the number of inversions is 5.
Your solution should read the input from standard input and output the result to standard output.
inputFormat
The first line contains a single integer \( n \), the number of elements in the list. The second line contains \( n \) space-separated integers.
outputFormat
Output a single integer representing the number of inversions in the list.
## sample5
2 3 8 6 1
5
</p>