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.*;

import static java.util.Arrays.*;
import static java.lang.Math.*;

public class Main {
	static boolean LOCAL = System.getSecurityManager() == null;
	Scanner in = new Scanner(System.in);
	PrintWriter out = new PrintWriter(System.out);

	void run() {
		while (in.hasNext())
			solve();
	}

	void solve() {
		int n = in.nextInt();
		int[] is = new int[n + 1];
		for (int i = 1; i <= n; i++) is[i] = in.nextInt();
		ArrayList<Integer> ps = getPrime(n);
		int[] index = new int[n + 1];
		for (int i = 1; i <= n; i++) index[is[i]] = i;
		int cnt = 0;
		StringBuilder sb = new StringBuilder();
		for (int i = 1; i <= n; i++) {
			if (index[i] == i) continue;
			int d = index[i] - i + 1;
			while (d != 1) {
				int id = upperBound(ps, d) - 1;
				int v = index[i], u = v + 1 - ps.get(id);
				sb.append(u);
				sb.append(' ');
				sb.append(v);
				sb.append(System.lineSeparator());
				cnt++;
				int tmp = is[u]; is[u] = is[v]; is[v] = tmp;
				index[is[u]] = u; index[is[v]] = v;
				d = index[i] - i + 1;
			}
		}
		out.println(cnt);
		out.print(sb);
	}
	int upperBound(ArrayList<Integer> ps, int d) {
		int l = 0, r = ps.size();
		while (l < r) {
			int m = (l + r) / 2;
			if (ps.get(m) > d) r = m;
			else l = m + 1;
		}
		return l;
	}
	ArrayList<Integer> getPrime(int n) {
		n += 100;
		boolean[] vis = new boolean[n];
		ArrayList<Integer> ps = new ArrayList<Integer>();
		for (int i = 2; i < n; i++) {
			if (!vis[i]) {
				ps.add(i);
				for (int j = i + i; j < n; j += i) vis[j] = true;
			}
		}
		return ps;
	}

	void debug(Object... os) {
		System.err.println(deepToString(os));
	}

	public static void main(String[] args) {
		long start = System.nanoTime();
		if (LOCAL) {
			try {
				System.setIn(new FileInputStream("./../in"));
				// System.setOut(new PrintStream("./../out.txt"));
			} catch (IOException e) {
				LOCAL = false;
			}
		}
		Main main = new Main();
		main.run();
		main.out.close();
		if (LOCAL)
			System.err.printf("[Time %.6fs]%n",
					(System.nanoTime() - start) * 1e-9);
	}
}

class Scanner {
	BufferedReader br;
	StringTokenizer st;

	Scanner(InputStream in) {
		br = new BufferedReader(new InputStreamReader(in));
		eat("");
	}

	private void eat(String string) {
		st = new StringTokenizer(string);
	}

	String nextLine() {
		try {
			return br.readLine();
		} catch (IOException e) {
			return null;
		}
	}

	boolean hasNext() {
		while (!st.hasMoreTokens()) {
			String s = nextLine();
			if (s == null)
				return false;
			eat(s);
		}
		return true;
	}

	String next() {
		hasNext();
		return st.nextToken();
	}

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

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

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