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.InputStream;
import java.io.PrintStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class CF246Div2C {

	Integer[] getPrime(int max) {
		ArrayDeque<Integer> prime = new ArrayDeque<Integer>();
		boolean isPrime[] = new boolean[max + 1];
		for (int i = 0; i < isPrime.length; i++) {
			isPrime[i] = true;
		}
		isPrime[0] = isPrime[1] = false;
		for (int i = 2; i < isPrime.length; i++) {
			if (isPrime[i]) {
				prime.add(i);
				for (int j = 2 * i; j < isPrime.length; j += i) {
					isPrime[j] = false;
				}
			}
		}
		for (int i = 0; i < isPrime.length; i++) {
			isPrime[i] = !isPrime[i];
		}

		//		return isPrime;
		return prime.toArray(new Integer[0]);
	}

	void solve(int n, int[] aOrg) {
		Integer[] primes = getPrime(100000);
		int[][] a = new int[n][];
		for (int i = 0; i < n; i++) {
			a[i] = new int[] { aOrg[i], i };
		}
		Arrays.sort(a, new Comparator<int[]>() {
			public int compare(int[] a, int[] b) {
				return a[0] - b[0];
			}
		});
		int[] ia = new int[n];
		for (int i = 0; i < n; i++)
			ia[a[i][1]] = i;
		List<String> lines = new ArrayList<String>();
		for (int i = 0; i < n; i++) {
			int j = a[i][1];
			while (j > i) {
				int pi = Arrays.binarySearch(primes, j - i + 1);
				if (pi < 0)
					pi = -pi - 2;
				int xj = j - primes[pi] + 1;
				lines.add((xj + 1) + " " + (j + 1));
				int xi = ia[xj];
				{
					int t = a[i][1];
					a[i][1] = a[xi][1];
					a[xi][1] = t;
				}
				{
					int t = ia[j];
					ia[j] = ia[xj];
					ia[xj] = t;
				}
				j = xj;
			}
		}
		out.println(lines.size());
		for (String line : lines) {
			out.println(line);
		}
	}

	void solve(InputStream in, PrintStream out) {
		sc = new Scanner(in);
		this.out = out;
		int n = ni();
		int[] a = na(n);
		solve(n, a);
	}

	// common codes hereinafter
	Scanner sc;
	PrintStream out;
	
	int ni() {
		return sc.nextInt();
	}

	int[] na(int n) {
		return na(n, 0);
	}
	
	int[] na(int n, int offset) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt() - offset;
		}
		return a;
	}

	int[][] na2(int n) {
		return na2(n, 0);
	}
	int[][] na2(int n, int offset) {
		int[][] a = new int[n][2];
		for (int i = 0; i < n; i++) {
			a[i][0] = sc.nextInt() - offset;
			a[i][1] = sc.nextInt() - offset;
		}
		return a;
	}

	public static void main(String[] args) {
		new CF246Div2C().solve(System.in, System.out);
	}
}
