IntermediateRating 1300
Fewest Swaps to Sort
The list is a permutation of 1 … n. Print the smallest number of swaps (any two positions) that sorts it.
Input
n, then the permutation.
Output
One integer.
Sample 1
Input
4 4 3 2 1
Output
2
Sample 2
Input
5 1 5 4 3 2
Output
2
Output appears here