You have an array a[1], a[2], ..., a[n], containing distinct integers from 1 to n. Your task is to sort this array in increasing order with the following operation (you may need to apply it multiple times):

  * choose two indexes, i and j (1 ≤ i < j ≤ n; (j - i + 1) is a prime number); 
  * swap the elements on positions i and j; in other words, you are allowed to apply the following sequence of assignments: tmp = a[i], a[i] = a[j], a[j] = tmp (tmp is a temporary variable). 



You do not need to minimize the number of used operations. However, you need to make sure that there are at most 5n operations.

Input

The first line contains integer n (1 ≤ n ≤ 105). The next line contains n distinct integers a[1], a[2], ..., a[n] (1 ≤ a[i] ≤ n).

Output

In the first line, print integer k (0 ≤ k ≤ 5n) — the number of used operations. Next, print the operations. Each operation must be printed as "i j" (1 ≤ i < j ≤ n; (j - i + 1) is a prime).

If there are multiple answers, you can print any of them.

Examples

Input

3
3 2 1


Output

1
1 3


Input

2
1 2


Output

0


Input

4
4 2 3 1


Output

3
2 4
1 2
2 4

import java.io.*;
import java.util.ArrayList;
import java.util.InputMismatchException;

public class C {
	FastScanner in = new FastScanner(System.in);
	PrintWriter out = new PrintWriter(System.out);

	boolean[] primeList = getPrimeList(100010);
	
	boolean[] getPrimeList(int n) {
		boolean[] res = new boolean[n];
		
		res[1] = true;
		for (int i = 2; i < res.length; i++) {
			if (res[i]) continue;
			for (int j = 2 * i; j < res.length; j += i) {
				res[j] = true;
			}
		}
		
		return res;
	}
	
	boolean isPrime(int x) {
		return !primeList[x];
	}
	
	void swap(int[] array, int i, int j) {
		int temp = array[i];
		array[i] = array[j];
		array[j] = temp;
		
	}
	
	public void run() {
		int n = in.nextInt();
		
		int[] place = new int[n+1];
		int[] array = new int[n];
		
		ArrayList<String> res = new ArrayList<String>();
		
		for (int i = 0; i < array.length; i++) {
			array[i] = in.nextInt();
			place[array[i]] = i;
		}
		
		for (int i = 1; i <= n; i++) {
			int pos = place[i];
			for (int j = i-1; array[i-1] != i; ) {
				if (isPrime(pos - j + 1)) {
					swap(place, array[pos], array[j]);
					swap(array, pos, j);
					res.add((j+1) +" " + (pos+1));
					pos = j;
					j = i-1;
				} else
					j++;
			}
		}
		
		out.println(res.size());
		for (int i = 0; i < res.size(); i++) {
			out.println(res.get(i));
		}
		out.close();
	}

	public static void main(String[] args) {
		new C().run();
	}

	public void debug(Object... obj) {
		for (int i = 0; i < obj.length; i++) {
			System.out.println(obj[i].toString());
		}
	}

	class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FastScanner(InputStream stream) {
			this.stream = stream;
			//stream = new FileInputStream(new File("dec.in"));

		}

		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++];
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}

