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.util.List;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.Writer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Niyaz Nigmatullin
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		FastPrinter out = new FastPrinter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
    static void swap(int i, int j, int[] a, int[] pos) {
        if (i == j) return;
        if (i > j) {
            int t = i;
            i = j;
            j = t;
        }
        int t = a[i];
        a[i] = a[j];
        a[j] = t;
        pos[a[i]] = i;
        pos[a[j]] = j;
        ax[ac] = i;
        ay[ac++] = j;
    }

    static int ac;
    static int[] ax;
    static int[] ay;

    public void solve(int testNumber, FastScanner in, FastPrinter out) {
        ac = 0;
        int[] primes = MathUtils.genPrimes(123456);
        boolean[] isPrime = MathUtils.genPrimesBoolean(123456);
        int n = in.nextInt();
        int[] a = new int[n];
        int[] pos = new int[n];
        ax = new int[5 * n];
        ay = new int[5 * n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt() - 1;
            pos[a[i]] = i;
        }
        for (int i = 0; i < n; i++) {
            int where = pos[i];
            int dif = where - i;
            if (dif == 0) {
                continue;
            }
            if (dif == 1) {
                swap(i, i + 1, a, pos);
                continue;
            }
            if ((dif & 1) == 1) {
                dif--;
                int found = findSwap(primes, isPrime, dif);
                int second = dif - (found - 1) + 1;
                swap(where, where - found + 1, a, pos);
                swap(i + 1 + second - 1, i + 1, a, pos);
                swap(i, i + 1, a, pos);
            } else {
                int found = findSwap(primes, isPrime, dif);
                int second = dif - (found - 1) + 1;
                swap(where, where - found + 1, a, pos);
                swap(i + second - 1, i, a, pos);
            }
        }
        for (int i = 0; i < n; i++) if (a[i] != i) throw new AssertionError();
        out.println(ac);
        for (int i = 0; i < ac; i++) {
            out.println((ax[i] + 1) + " " + (ay[i] + 1));
        }
    }

    private int findSwap(int[] primes, boolean[] isPrime, int dif) {
        int found = -1;
        for (int j : primes) {
            if (isPrime[dif - (j - 1) + 1]) {
                found = j;
                break;
            }
        }
        if (found < 0) throw new AssertionError();
        return found;
    }

}

class FastScanner extends BufferedReader {

    public FastScanner(InputStream is) {
        super(new InputStreamReader(is));
    }

    public int read() {
        try {
            int ret = super.read();
//            if (isEOF && ret < 0) {
//                throw new InputMismatchException();
//            }
//            isEOF = ret == -1;
            return ret;
        } catch (IOException e) {
            throw new InputMismatchException();
        }
    }

    static boolean isWhiteSpace(int c) {
        return c >= 0 && c <= 32;
    }

    public int nextInt() {
        int c = read();
        while (isWhiteSpace(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int ret = 0;
        while (c >= 0 && !isWhiteSpace(c)) {
            if (c < '0' || c > '9') {
                throw new NumberFormatException("digit expected " + (char) c
                        + " found");
            }
            ret = ret * 10 + c - '0';
            c = read();
        }
        return ret * sgn;
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }

}

class FastPrinter extends PrintWriter {

    public FastPrinter(OutputStream out) {
        super(out);
    }

    public FastPrinter(Writer out) {
        super(out);
    }


}

class MathUtils {


    public static int[] genPrimes(int n) {
        boolean[] isPrime = genPrimesBoolean(n);
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (isPrime[i]) {
                count++;
            }
        }
        int[] primes = new int[count];
        for (int i = 0, j = 0; i < n; i++) {
            if (isPrime[i]) {
                primes[j++] = i;
            }
        }
        return primes;
    }

    public static boolean[] genPrimesBoolean(int n) {
        boolean[] isPrime = new boolean[n];
        Arrays.fill(isPrime, true);
        isPrime[0] = isPrime[1] = false;
        for (int i = 2; i * i < n; i++) {
            if (!isPrime[i]) {
                continue;
            }
            for (int j = i * i; j < n; j += i) {
                isPrime[j] = false;
            }
        }
        return isPrime;
    }

}

