eolymp
bolt
Try our new interface for solving problems
Problems

Bubble sort

Bubble sort

Determine how many exchange operations are done in bubble sort algorithm to sort the elements of array in ascending order.

Input

The first line contains the number of elements n (1n1000) in array. The second line contains the array itself. It is guaranteed that all array elements are different and do not exceed 109 by absolute value.

Output

Print the number of swaps in bubble sort.

Time limit 1 second
Memory limit 64 MiB
Input example #1
3
1 3 2
Output example #1
1
Input example #2
2
2 1
Output example #2
1
Input example #3
4
4 1 5 3
Output example #3
3