## Mock CCC '18 Contest 5 J4/S2 - Reverse Sort

View as PDF

Points: 5 (partial)
Time limit: 1.0s
Memory limit: 1G

Problem type

Given a permutation of the first positive integers and the ability to swap any two adjacent integers, compute the minimum number of swaps needed to sort the list in decreasing order.

#### Constraints

form a permutation of the first positive integers.

#### Input Specification

The first line of the input consists of a single integer, .

The next line contains space-separated integers, the permutation of the first integers.

#### Output Specification

Output, on a single line, the minimum number of swaps needed.

#### Sample Input

3
2 1 3

#### Sample Output

2