Sort from 0 to n - 1#8636

Sort from 0 to n - 1

1 second
128 megabytes
Medium

You are given a sequence of integers a_0, a_1, \dots, a_{n-1} consisting of pairwise distinct elements, each belonging to the range [0; n - 1].

An operation (i, j)~(0 \le i, j \le n - 1) is called a swap, which exchanges the values of a_i and a_j.

Sort the sequence in ascending order using the minimum number of swaps. Print all performed swaps.

Input

The first line contains one positive integer n~(n \le 10^6).

The second line contains distinct integers from the range [0; n - 1].

Output

In the first line, print the minimum number of swaps .

In the following lines, print all performed swaps as pairs .

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading