Problem: You are given a permutation p of integers from 1 to n, where n is an even number. 

Your goal is to sort the permutation. To do so, you can perform zero or more operations of the following type: 

  * take two indices i and j such that 2 ⋅ |i - j| ≥ n and swap p_i and p_j. 



There is no need to minimize the number of operations, however you should use no more than 5 ⋅ n operations. One can show that it is always possible to do that.

Input

The first line contains a single integer n (2 ≤ n ≤ 3 ⋅ 10^5, n is even) — the length of the permutation. 

The second line contains n distinct integers p_1, p_2, …, p_n (1 ≤ p_i ≤ n) — the given permutation.

Output

On the first line print m (0 ≤ m ≤ 5 ⋅ n) — the number of swaps to perform.

Each of the following m lines should contain integers a_i, b_i (1 ≤ a_i, b_i ≤ n, |a_i - b_i| ≥ n/2) — the indices that should be swapped in the corresponding swap.

Note that there is no need to minimize the number of operations. We can show that an answer always exists.

Examples

Input


2
2 1


Output


1
1 2

Input


4
3 4 1 2


Output


4
1 4
1 4
1 3
2 4


Input


6
2 5 3 1 4 6


Output


3
1 5
2 5
1 4

Note

In the first example, when one swap elements on positions 1 and 2, the array becomes sorted.

In the second example, pay attention that there is no need to minimize number of swaps.

In the third example, after swapping elements on positions 1 and 5 the array becomes: [4, 5, 3, 1, 2, 6]. After swapping elements on positions 2 and 5 the array becomes [4, 2, 3, 1, 5, 6] and finally after swapping elements on positions 1 and 4 the array becomes sorted: [1, 2, 3, 4, 5, 6].

Solution (in JAVA):

Solution:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Iterator;
import java.util.PriorityQueue;
import java.util.TreeMap;
import java.util.TreeSet;

public class Solution1 implements Runnable {
	static final long MAX = 464897L;

	static class InputReader {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;
		private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int read() {
			if (numChars == -1)
				throw new InputMismatchException();

			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}

				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		public int nextInt() {
			int c = read();

			while (isSpaceChar(c))
				c = read();

			int sgn = 1;

			if (c == '-') {
				sgn = -1;
				c = read();
			}

			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));

			return res * sgn;
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;

			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public double nextDouble() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			double res = 0;
			while (!isSpaceChar(c) && c != '.') {
				if (c == 'e' || c == 'E')
					return res * Math.pow(10, nextInt());
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			if (c == '.') {
				c = read();
				double m = 1;
				while (!isSpaceChar(c)) {
					if (c == 'e' || c == 'E')
						return res * Math.pow(10, nextInt());
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					m /= 10;
					res += (c - '0') * m;
					c = read();
				}
			}
			return res * sgn;
		}

		public String readString() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));

			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public String next() {
			return readString();
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}

	public static void main(String args[]) throws Exception {
		new Thread(null, new Solution1(), "Solution1", 1 << 26).start();
	}

	static long gcd(long a, long b) {
		if (b == 0)
			return a;
		return gcd(b, a % b);
	}

	static long lcm(long a, long b) {
		return (a * b) / gcd(a, b);
	}

	int maxn = 1000005;
	long MOD = 998244353;
	long prime = 29;
	ArrayList<Pair> adj[];
	TreeMap<Long, Long> tmap = new TreeMap();
	int[] val;
	int[] ans;
	long[] arr;
	ArrayList<Long> segTree[];
	public void run() {
		InputReader sc = new InputReader(System.in);
		PrintWriter w = new PrintWriter(System.out);
		int n = sc.nextInt();
		int[] arr=  new int[n+1];
	
		TreeMap<Integer,Integer> tmap = new TreeMap();
		TreeMap<Integer,Integer> tmap2 = new TreeMap();

		for(int i = 1;i <= n;i++) {
			arr[i] = sc.nextInt();
			tmap.put(arr[i],i);
			tmap2.put(i, arr[i]);
		}
		ArrayList<Pair> ar = new ArrayList();
		for(int i = 1;i <= n;i++) {
			int x = tmap.get(i);
			if(x == i) {
				continue;
			}
			if(Math.abs(x - i) * 2 >= n) {
				ar.add(swap(tmap,tmap2,i,x));
			}else {
				if((x - 1) * 2 >= n) {
					ar.add(swap(tmap,tmap2,x,1));
					if((i - 1) * 2 >= n) {
						ar.add(swap(tmap,tmap2,i,1));
						ar.add(swap(tmap,tmap2,1,x));
					}else {
						ar.add(swap(tmap,tmap2,1,n));
						ar.add(swap(tmap,tmap2,1,x));
						ar.add(swap(tmap,tmap2,n,i));
					}
				}else {
					ar.add(swap(tmap,tmap2,x,n));
					if((n - i) * 2 >= n) {
						ar.add(swap(tmap,tmap2,i,n));
					}else {
						ar.add(swap(tmap,tmap2,1,n));
						ar.add(swap(tmap,tmap2,1,i));
						ar.add(swap(tmap,tmap2,n,1));
					}
				}
			}
		}
		w.println(ar.size());
		for(int i = 0;i < ar.size();i++) {
			w.println(ar.get(i).a + " " + ar.get(i).b);
		}
		w.close();
	}
	Pair swap(TreeMap<Integer,Integer> tmap,TreeMap<Integer,Integer> tmap2,int i,int x) {
		int temp = tmap2.get(x);
		tmap2.put(x, tmap2.get(i));
		tmap2.put(i, temp);
		tmap.put(tmap2.get(x), x);
		tmap.put(tmap2.get(i),i);
		return (new Pair(i,x,1));
	}
	
	static long power(long a, long b, long mod) {
		long ans = 1;
		a = a % mod;
		while (b != 0) {
			if (b % 2 == 1) {
				ans = (ans * a) % mod;
			}
			a = (a * a) % mod;
			b = b / 2;
		}
		return ans;
	}

	class Pair implements Comparable<Pair> {
		int a;
		int b;
		long c;

		Pair(int a, int b, long c) {
			this.b = b;
			this.a = a;
			this.c = c;
		}

		public boolean equals(Object o) {
			Pair p = (Pair) o;
			return this.a == p.a && this.b == this.b;
		}

		public int hashCode() {
			return Long.hashCode(a) * 27 + Long.hashCode(b) * 31;
		}
		public int compareTo(Pair p) {
			return Long.compare(this.b, p.b);
		}
	}

	class Pair2 implements Comparable<Pair2> {
		int a;
		long b;
		int c;

		Pair2(int a, long b, int c) {
			this.b = b;
			this.a = a;
			this.c = c;
		}

		public boolean equals(Object o) {
			Pair p = (Pair) o;
			return this.a == p.a && this.b == this.b;
		}

		public int hashCode() {
			return Long.hashCode(a) * 27 + Long.hashCode(b) * 31;
		}

		public int compareTo(Pair2 p) {
			return Long.compare(this.b, p.b);
		}
	}
}