#arc162b. [arc162_b]Insertion Sort 2

[arc162_b]Insertion Sort 2

Problem Statement

A permutation P=(P1,P2,ldots,PN)P=(P_1,P_2,\\ldots,P_N) of (1,2,ldots,N)(1,2,\\ldots,N) is given.

Determine whether it is possible to rearrange PP in ascending order by performing the following operation at most 2times1032\\times 10^3 times, and if possible, show one such sequence of operations.

  • Choose integers ii and jj such that 1leqileqN1,0leqjleqN21\\leq i \\leq N-1,0 \\leq j \\leq N-2. Let Q=(Q1,Q2,ldots,QN2)Q = (Q_1, Q_2,\\ldots,Q_{N-2}) be the sequence obtained by removing (Pi,Pi+1)(P_i,P_{i+1}) from PP. Replace PP with $(Q_1,\\ldots,Q_j, P_i, P_{i+1}, Q_{j+1},\\ldots,Q_{N-2})$.

Constraints

  • 2leqNleq1032 \\leq N \\leq 10^3
  • PP is a permutation of (1,2,ldots,N)(1,2,\\ldots,N).
  • All input values are integers.

Input

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

NN P1P_1 P2P_2 ldots\\ldots PNP_N

Output

If PP cannot be rearranged in ascending order within 2times1032\\times 10^3 operations, print No. If it can be rearranged in ascending order, let M(0leqMleq2times103)M\\ (0 \\leq M \\leq 2\\times 10^3) be the number of operations, and ik,jki_k,j_k be the chosen i,ji,j for the kk-th operation (1leqkleqM)(1\\leq k \\leq M), and print them in the following format:

Yes MM i1i_1 j1j_1 i2i_2 j2j_2 vdots\\vdots iMi_M jMj_M

If there are multiple solutions, any of them will be considered correct.


Sample Input 1

5
1 4 2 3 5

Sample Output 1

Yes
1
3 1

Perform the operation with i=3,j=1i=3,j=1.

Then, Q=(P1,P2,P5)=(1,4,5)Q=(P_1,P_2,P_5)=(1,4,5), so you get P=(Q1,P3,P4,Q2,Q3)=(1,2,3,4,5)P=(Q_1,P_3,P_4,Q_2,Q_3) = (1,2,3,4,5).

Thus, PP can be rearranged in ascending order with one operation.


Sample Input 2

2
2 1

Sample Output 2

No

It can be proved that PP cannot be rearranged in ascending order within 2times1032\\times 10^3 operations.


Sample Input 3

4
3 4 1 2

Sample Output 3

Yes
3
3 0
1 2
3 0

There is no need to minimize the number of operations.