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.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(in, out);
		out.close();
	}
}

class Pair {
	public int x, y;

	public Pair(int a, int b) {
		x = a;
		y = b;
	}

	public int x() {return x;}
	public int y() {return y;}
}

class Task {

	public void solve(InputReader in, PrintWriter out) {
		int n = in.nextInt();
		int[] A = new int[n+1];
		int[] pos = new int[n+1];
		boolean[] sieve = new boolean[n+1];
		ArrayList<Integer> primes = new ArrayList<Integer>();
		ArrayList<Pair> res = new ArrayList<Pair>();

		for(int i = 1; i <= n; ++i) {
			A[i] = in.nextInt();
			pos[A[i]] = i;
		}

		Arrays.fill(sieve, true);
		sieve[1] = false;
		for(int i = 2; i*i <= n; ++i) {
			if(sieve[i]) {
				for(int j = i*i; j <= n; j+=i) {
					sieve[j] = false;
				}
			}
		}

		for(int i = 1; i <= n; ++i) {
			if(sieve[i])
				primes.add(i);
			//out.println(i+" "+sieve[i]);
		}

		//out.println(Collections.binarySearch(primes, 6));

		int[] prime = new int[primes.size()];
		for(int i = 0; i < primes.size(); ++i) {
			prime[i] = primes.get(i);
		}

		for(int i = 1; i <= n; ++i) {
			setOnPosition(A, pos, prime, i, res, out);
		}

		/*for(int i = 1; i <= n; ++i) {
			out.print(A[i]+" ");
		}*/

		out.println(res.size());
		for(int i = 0; i < res.size(); ++i) {
			out.println(res.get(i).x+" "+res.get(i).y);
		}
	}

	public static void setOnPosition(int[] A, int[] pos, int[] primes, int current, ArrayList<Pair> res, PrintWriter out) {
		while(true) {
			int distance = pos[current]-current+1;

			if(distance == 1)
				return;
			
			int start = 0, end = primes.length-1, found = 0;
			while(start <= end) {
				int mid = (start+end)/2;
				if(primes[mid]<distance)
					start = mid+1;
				else if(primes[mid]>distance)
					end = mid-1;
				else {
					found = primes[mid];
					break;
				}
			}

			if(found == 0 && end == -1)
				end = 0;

			if(found == 0)
				found = primes[end];
			found--;

			//out.println(pos[A[pos[current]-found]]+" "+pos[current]);
			Pair p = new Pair(pos[A[pos[current]-found]],pos[current]);
			res.add(p);

			//out.println("#1 found:"+found+"; start:"+start+"; end:"+end+"; current:"+current+"; pos[current]:"+pos[current]+"; A[pos[current]]:"+A[pos[current]]+"; A[pos[current]-found]:"+A[pos[current]-found]+"; pos[A[pos[current]-found]]:"+pos[A[pos[current]-found]]+";");

			int temp = A[pos[current]];
			A[pos[current]] = A[pos[current]-found];
			A[pos[current]-found] = temp;


			//out.println("#2 found:"+found+"; start:"+start+"; end:"+end+"; current:"+current+"; pos[current]:"+pos[current]+"; A[pos[current]]:"+A[pos[current]]+"; A[pos[current]-found]:"+A[pos[current]-found]+"; pos[A[pos[current]]]:"+pos[A[pos[current]]]+";");

			
			temp = pos[current];
			int temp1 = A[pos[current]];
			pos[current] = pos[A[pos[current]]];
			pos[temp1] = temp;
			
			//out.println("#3 pos[current]:"+pos[current]+"; pos[A[pos[current]]]:"+pos[temp1]+";");


			if(found+1 != primes[end])
				break;
		}
	}
}

class InputReader {
	public BufferedReader reader;
	public StringTokenizer tokenizer;

	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream), 32768);
		tokenizer = null;
	}

	public String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

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

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