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 static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");

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

	void run() throws IOException {
		// in = new BufferedReader(new FileReader("input.txt"));
		// out = new PrintWriter("output.txt");

		if (new File("input.txt").exists())
			in = new BufferedReader(new FileReader("input.txt"));
		else
			in = new BufferedReader(new InputStreamReader(System.in));
		if (new File("output.txt").exists())
			out = new PrintWriter("output.txt");
		else
			out = new PrintWriter(System.out);

		solve();

		in.close();
		out.close();
	}

	int maxn = 100 * 1000 + 100;

	int n;
	int a[] = new int[maxn];

	boolean isPrime[] = new boolean[maxn];
	int prime[] = new int[maxn];
	int cntPrime;

	int ans1[] = new int[5 * maxn];
	int ans2[] = new int[5 * maxn];
	int cntAns = 0;

	int index[] = new int[maxn];

	void preCalc() {
		cntPrime = 0;
		fill(isPrime, true);
		isPrime[0] = isPrime[1] = false;
		for (int i = 2; ((long) i) * i < maxn; i++)
			if (isPrime[i])
				for (int j = i * i; j < maxn; j += i)
					isPrime[j] = false;
		for (int i = 2; i < maxn; i++)
			if (isPrime[i])
				prime[cntPrime++] = i;
	}

	void swap(int i, int j) {
		ans1[cntAns] = i + 1;
		ans2[cntAns++] = j + 1;
		index[a[i]] = j;
		index[a[j]] = i;
		int tmp = a[i];
		a[i] = a[j];
		a[j] = tmp;
	}

	void solve() throws IOException {
		n = nextInt();
		for (int i = 0; i < n; i++)
			index[a[i] = (nextInt() - 1)] = i;

		preCalc();
		for (int num = n - 1; num >= 0; num--) {
			while (a[num] != num) {
				int i = index[num];
				int key = num - i + 1;
				int p = binarySearch(prime, 0, cntPrime, key);
				if (p >= 0) {
					swap(i, num);
				} else {
					p = prime[(-p - 1) - 1];
					swap(i, i + p - 1);
				}
			}
		}

		out.println(cntAns);
		for (int i = 0; i < cntAns; i++)
			out.println(ans1[i] + " " + ans2[i]);

		// for (int i = 0; i<n; i++)
		// System.err.println(a[i]);
	}

	String nextToken() throws IOException {
		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

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

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

	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}

}
