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.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class CF246Div2C {

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

	void solve(int n, int[] a) {
		boolean[] isPrime = getIsPrime(n);
		int[] idx = new int[n];
		for (int i = 0; i < n; i++) {
			idx[a[i]] = i;
		}
		int[] x = new int[5 * n], y = new int[5 * n];
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			if (idx[i] == i)
				continue;
			int cur = idx[i];
			while (cur > i) {
				for (int j = i; j < cur; j++) {
					if (isPrime[cur - j + 1]) {
						cnt++;
						x[cnt] = j + 1;
						y[cnt] = cur + 1;
						idx[a[j]] = cur;
						a[cur] = a[j];
						cur = j;
						break;
					}
				}
			}
		}
		pw.println(cnt);
		for (int i = 1; i <= cnt; i++) {
			pw.println(x[i] + " " + y[i]);
		}
	}

	void solve(InputStream in, PrintStream out) {
		br = new BufferedReader(new InputStreamReader(in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(out)));;
		int n = ni();
		int[] a = na(n, 1);
		solve(n, a);
        pw.close();
	}

	/*
	 *  common codes hereinafter
	 */

    static StringTokenizer st;
    static BufferedReader br;
    static PrintWriter pw;

    String next() {
        while (st==null || !st.hasMoreTokens())
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				e.printStackTrace();
				System.exit(1);
			}
        return st.nextToken();
    }
    
	int ni() {
        return Integer.parseInt(next());
	}

	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] = ni() - 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] = ni() - offset;
			a[i][1] = ni() - offset;
		}
		return a;
	}

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