Sort from 0 to n - 1
Medium
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Given a sequence of numbers consisting of unique elements, each of which belongs to the range . A swap is defined as an operation that exchanges the values of and . Sort the sequence using the minimum number of swaps. Print all the swaps performed.
Input
The first line contains a positive integer . The second line contains distinct numbers from the range .
Output
In the first line print the minimum number of performed swaps . In the next lines print all the swaps in the form of pairs .
Examples
Input #1
Answer #1
Input #2
Answer #2
Submissions 618
Acceptance rate 25%