~/algor $ cat problems/saralash-almashtirishlar-soni
Swaps to sort
Medium
1000 ms
128 MB
56%
$n$ distinct integers are given. In one operation any two elements can be swapped. What is the smallest number of operations needed to sort the array in increasing order?
Input
The first line contains a positive integer $n$. The second line contains $n$ distinct integers $a_{i}$.
Output
One integer — the smallest number of operations.
Note
$1 \le n \le 2 \cdot 10^{5}$
$-10^{9} \le a_{i} \le 10^{9}$, all $a_{i}$ are distinct
Examples
Input #1
5 4 3 1 5 2
Output #1
4
Input #2
1 10
Output #2
0