Problem10113--ABC350 —— C - Sort

10113: ABC350 —— C - Sort

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 512 MiB

Description

You are given a permutation $A=(A_1,\ldots,A_N)$ of $(1,2,\ldots,N)$.  
Transform $A$ into $(1,2,\ldots,N)$ by performing the following operation between $0$ and $N-1$ times, inclusive:

-   Operation: Choose any pair of integers $(i,j)$ such that $1\leq i < j \leq N$. Swap the elements at the $i$-th and $j$-th positions of $A$.

It can be proved that under the given constraints, it is always possible to transform $A$ into $(1,2,\ldots,N)$.

Input

The input is given from Standard Input in the following format:

```
$N$
$A_1$ $\ldots$ $A_N$
```

Output

Let $K$ be the number of operations. Print $K+1$ lines.  
The first line should contain $K$.  
The $(l+1)$-th line ($1\leq l \leq K$) should contain the integers $i$ and $j$ chosen for the $l$-th operation, separated by a space.  
Any output that satisfies the conditions in the problem statement will be considered correct.

Constraints

-   $2 \leq N \leq 2\times 10^5$
-   $(A_1,\ldots,A_N)$ is a permutation of $(1,2,\ldots,N)$.
-   All input values are integers.

Sample 1 Input

5
3 4 1 2 5

Sample 1 Output

2
1 3
2 4

The operations change the sequence as follows:

  • Initially, A=(3,4,1,2,5).
  • The first operation swaps the first and third elements, making A=(1,4,3,2,5).
  • The second operation swaps the second and fourth elements, making A=(1,2,3,4,5).

Other outputs such as the following are also considered correct:

4
2 3
3 4
1 2
2 3

Sample 2 Input

4
1 2 3 4

Sample 2 Output

0

Sample 3 Input

3
3 1 2

Sample 3 Output

2
1 2
2 3

Source/Category