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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

public class PrimeSwaps {

	static int n;
	static int[] a;
	static int[] pos;
	static boolean[] primes;

	void GeneratePrime(int max) {
		primes = new boolean[max + 1];
		Arrays.fill(primes, true);
		primes[0] = primes[1] = false;
		int length = primes.length;
		for (int i = 2; i * i < length; i++) {
			if (primes[i]) {
				for (int j = i * i; j < length; j += i) {
					primes[j] = false;
				}
			}
		}
	}

	public static void main(String[] args) throws IOException {
		PrimeSwaps main = new PrimeSwaps();
		main.input();
		// main.GenerateTestcase(100000);
		// long current = System.currentTimeMillis();
		main.solve();
		// System.out.println("time test :"
		// + (System.currentTimeMillis() - current) + " ms");
	}

	void input() throws IOException {
		Init(System.in);
		n = NextInt();
		GeneratePrime(n);
		a = new int[n];
		pos = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = NextInt();
			pos[a[i] - 1] = i;
		}
	}

	void GenerateTestcase(int m) {
		n = m;
		GeneratePrime(n);
		a = new int[n];
		pos = new int[n];
		List<Integer> aa = new ArrayList<Integer>();
		for (int i = n; i > 0; i--) {		
			aa.add(i);
		}

		// Collections.shuffle(aa);
		for (int i = 0; i < n; i++) {
			a[i] = aa.get(i);
			pos[a[i] - 1] = i;
			//System.out.print(aa.get(i) + " ");
		}

	}

	void solve() {
		int nOperations = 0;
		int left = 0;
		int right = 0;
		int length = a.length;
		int temp = 0;
		StringBuilder res = new StringBuilder();
		int k = 0;
		for (int i = 0; i < length; i++) {
			while (a[i] != i + 1) {
				left = i;
				right = pos[i];
				while (!primes[right - left + 1]) {
					left++;
				}
				nOperations++;
				pos[a[right] - 1] = left;
				pos[a[left] - 1] = right;

				temp = a[right];
				a[right] = a[left];
				a[left] = temp;

				res.append((left + 1) + " " + (right + 1) + "\n");

			}
		}
		System.out.println(nOperations);
		System.out.print(res);

	}

	/*****************************************************************
	 ******************** READER *******************************
	 *****************************************************************/
	static BufferedReader reader;
	static StringTokenizer tokenizer;

	static void Init(InputStream input) {
		reader = new BufferedReader(new InputStreamReader(input));
		tokenizer = new StringTokenizer("");
	}

	static String Next() throws IOException {
		while (!tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}

	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());
	}

}