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


public class Main {
	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;
	
	static int[] a, pos;
	static ArrayList<Integer> res = new ArrayList<Integer>();
	static ArrayList<Integer> p = new ArrayList<Integer>();
	
	static void solve() throws Exception {
		int n = nextInt();
		a = new int[n+1];
		pos = new int[n+1];
		for (int i = 1; i <= n; i++) {
			a[i] = nextInt();
			pos[a[i]] = i;
		}
		boolean[] used = new boolean[n+1];
		for (int i = 2; i*i <= n; i++) {
			if (!used[i]) {
				for (int j = i*i; j <= n; j += i) {
					used[j] = true;
				}
			}
		}
		for (int i = 2; i <= n; i++) {
			if (!used[i]) {
				p.add(i);
			}
		}
		for (int i = 1; i <= n; i++) {
			while (a[i] != i) {
				swap(pos[i] - binsearch(pos[i]-i+1) + 1, pos[i]);
			}
		}
        out.println(res.size() / 2);
        for (int i = 0; i < res.size(); i += 2) {
        	out.println(res.get(i) + " " + res.get(i+1));
        }
	}
	
	static int binsearch(int v) {
		int l = 0;
		int r = p.size()-1;
		int res = 0;
		while (l <= r) {
			int m = (l+r) / 2;
			if (p.get(m) <= v) {
				res = m;
				l = m+1;
			} else {
				r = m-1;
			}
		}
		return p.get(res);
	}
	
	static void swap(int i, int j) {
		res.add(i);
		res.add(j);
		int x = a[i];
		int y = a[j];
		a[i] = y;
		a[j] = x;
		pos[x] = j;
		pos[y] = i;
	}
	
	static int sqr(int x) {
		return x*x;
	}
	
	static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

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

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

	static BigInteger nextBigInteger() throws IOException {
		return new BigInteger(next());
	}
	
	static String next() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}
	
	static String nextLine() throws IOException {
		tok = new StringTokenizer("");
		return in.readLine();
	}

	static boolean hasNext() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null) {
				return false;
			}
			tok = new StringTokenizer(s);
		}
		return true;
	}

	public static void main(String args[]) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(new OutputStreamWriter(System.out));
			//in = new BufferedReader(new FileReader("1.in"));
			//out = new PrintWriter(new FileWriter("1.out"));
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			java.lang.System.exit(1);
		}
	}
}