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.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

import javax.management.RuntimeErrorException;

public class Template implements Runnable {

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

	void init() throws FileNotFoundException {
		try {
			in = new BufferedReader(new FileReader("input.txt"));
			out = new PrintWriter("output.txt");
		} catch (Exception e) {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
		}
	}

	class GraphBuilder {
		int n, m;
		int[] x, y;
		int index;
		int[] size;

		GraphBuilder(int n, int m) {
			this.n = n;
			this.m = m;
			x = new int[m];
			y = new int[m];
			size = new int[n];
		}

		void add(int u, int v) {
			x[index] = u;
			y[index] = v;
			size[u]++;
			size[v]++;
			index++;
		}

		void addDir(int u, int v) {
			x[index] = u;
			y[index] = v;
			size[u]++;
			index++;
		}

		int[][] buildDir() {
			int[][] graph = new int[n][];
			for (int i = 0; i < n; i++) {
				graph[i] = new int[size[i]];
			}
			for (int i = m - 1; i >= 0; i--) {
				graph[x[i]][--size[x[i]]] = y[i];
			}
			return graph;
		}

		int[][] build() {
			int[][] graph = new int[n][];
			for (int i = 0; i < n; i++) {
				graph[i] = new int[size[i]];
			}
			for (int i = m - 1; i >= 0; i--) {
				graph[x[i]][--size[x[i]]] = y[i];
				graph[y[i]][--size[y[i]]] = x[i];
			}
			return graph;
		}
	}

	String readString() throws IOException {
		while (!tok.hasMoreTokens()) {
			try {
				tok = new StringTokenizer(in.readLine());
			} catch (Exception e) {
				return null;
			}
		}
		return tok.nextToken();
	}

	int readInt() throws IOException {
		return Integer.parseInt(readString());
	}

	int[] readIntArray(int size) throws IOException {
		int[] res = new int[size];
		for (int i = 0; i < size; i++) {
			res[i] = readInt();
		}
		return res;
	}

	long readLong() throws IOException {
		return Long.parseLong(readString());
	}

	double readDouble() throws IOException {
		return Double.parseDouble(readString());
	}

	<T> List<T>[] createGraphList(int size) {
		List<T>[] list = new List[size];
		for (int i = 0; i < size; i++) {
			list[i] = new ArrayList<>();
		}
		return list;
	}

	public static void main(String[] args) {
		new Template().run();
		// new Thread(null, new Template(), "", 1l * 200 * 1024 * 1024).start();
	}

	long timeBegin, timeEnd;

	void time() {
		timeEnd = System.currentTimeMillis();
		System.err.println("Time = " + (timeEnd - timeBegin));
	}

	long memoryTotal, memoryFree;

	void memory() {
		memoryFree = Runtime.getRuntime().freeMemory();
		System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10) + " KB");
	}

	public void run() {
		try {
			timeBegin = System.currentTimeMillis();
			memoryTotal = Runtime.getRuntime().freeMemory();
			init();
			solve();
			out.close();
			if (System.getProperty("ONLINE_JUDGE") == null) {
				time();
				memory();
			}
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(-1);
		}
	}

	int[] a;
	int[] ind;

	void swap(int i, int j) {
		int t = a[i];
		a[i] = a[j];
		a[j] = t;
		ind[a[i]] = i;
		ind[a[j]] = j;
	}

	int lower(boolean[] isPrime, int factLen) {
		if (isPrime[factLen + 1]) {
			return factLen + 1;
		}
		if (factLen % 2 == 1) {
			return 2;
		}
		for (int i = 2;; i++) {
			if (isPrime[i] && isPrime[factLen + 2 - i])
				return i;
		}
	}

	void solve() throws IOException {
		int n = readInt();
		a = readIntArray(n);
		ind = new int[n];
		for (int i = 0; i < n; i++) {
			a[i]--;
			ind[a[i]] = i;
		}
		boolean[] isPrime = new boolean[100000 + 10];
		Arrays.fill(isPrime, true);
		isPrime[0] = isPrime[1] = false;
		for (int i = 2; i < isPrime.length; i++) {
			for (int j = i * 2; j < isPrime.length; j += i) {
				isPrime[j] = false;
			}
		}
		List<String> answer = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			while (true) {
				int wh = ind[i];
				if (wh == i)
					break;
				int lower = lower(isPrime, wh - i);
				int secondIndex = wh - lower + 1;
				int min = Math.min(wh, secondIndex);
				int max = Math.max(wh, secondIndex);
				swap(wh, secondIndex);
				answer.add((min + 1) + " " + (max + 1));
			}
		}
		out.println(answer.size());
		for (String s : answer) {
			out.println(s);
		}

	}

}