#8. Life Will Change

Life Will Change

Problem Statement

Given a permutation of length nn, p1,p2,p3,,pnp_1, p_2, p_3, \dots, p_n, you can perform an operation where you swap two elements pip_i and pjp_j, with 1i,jn1 \leq i , j \leq n.

Your task is to sort the permutation in ascending order 1,2,3,,n1, 2, 3, \dots, n in at most n1n - 1 operations. You need to output a sequence of operations that achieves this.

Input

The first line contains an integer nn, the length of the permutation (2n106)(2 \leq n \leq 10^6).

The second line contains nn integers p1,p2,p3,,pnp_1, p_2, p_3, \dots, p_n, representing the given permutation. It is guaranteed that each integer from 11 to nn appears exactly once.

Output

On the first line, output an integer kk, the number of operations required.

In the following kk lines, output two integers xx and yy per line, indicating a swap between pxp_x and pyp_y (1x,yn)(1 \leq x , y \leq n).

Example

Input

5
3 4 1 5 2

Output

3
1 3
2 4
5 2

Constraints

  • For all inputs, 2n1062 \leq n \leq 10^6.
  • There may be multiple valid solutions; you only need to output one solution that satisfies the conditions.

To handle large input and output efficiently, you can use faster I/O methods in C++.

In C++, you can use the following lines at the beginning of your main function:

ios::sync_with_stdio(false);
cin.tie(nullptr);

This will speed up I/O operations by disabling the synchronization between C++ and C I/O streams and untie cin from cout, making cin operate independently of cout.