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.Arrays;
import java.util.StringTokenizer;

/**
 *
 * @author Hidayat
 */
public class C246 {

    static int numOfOps = 0;
    static final int mx = 100100;
    static int input[];
    static int idx[];
    static int a[] = new int[mx];
    static int primes[] = new int[mx];
    static int primeCnt = 0;

    static void findPrimes(int n) {
        Arrays.fill(a, 1);
        for (int i = 2; i <= (int) Math.sqrt(n); i++) {
            if (a[i] == 1) {
                for (int j = i * i; j <= n; j += i) {
                    a[j] = 0;
                }
            }
        }

        for (int i = 2; i <= n; i++) {
            if (a[i] == 1) {
                primes[++primeCnt] = i;
            }
        }
    }

    static int binarySearch(int x, int lo, int hi) {
        if (lo >= hi) {
            return primes[lo];
        }
        int mid = (lo + hi) / 2;
        if (x == primes[mid]) {
            return primes[mid];
        }
        if (x > primes[mid]) {
            if (x < primes[mid + 1]) {
                return primes[mid];
            }
            return binarySearch(x, mid + 1, hi);
        } else {
            return binarySearch(x, lo, mid - 1);
        }
    }

    public static void main(String args[]) throws IOException {
        Reader.init(System.in);
        int n = Reader.nextInt();
        input = new int[n + 1];
        idx = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            input[i] = Reader.nextInt();
            idx[input[i]] = i;
        }

        findPrimes(n);



        int r1[] = new int[10 * mx];
        int r2[] = new int[10 * mx];

        for (int i = 1; i <= n; i++) {

            while (idx[i] != i) {
                int bsidx = binarySearch(idx[i] - i + 1, 1, primeCnt);
                int swapidx = idx[i] + 1 - bsidx;
                numOfOps++;
                r1[numOfOps] = swapidx;
                r2[numOfOps] = idx[i];
                int temp = input[swapidx];
                input[swapidx] = i;
                input[idx[i]] = temp;
                int tempValue = idx[i];
                idx[i] = swapidx;
                idx[temp] = tempValue;
            }

        }
        System.out.println(numOfOps);
        for (int i = 1; i <= numOfOps; i++) {
            System.out.println(r1[i] + " " + r2[i]);
        }


    }

    static class 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()) {
                //TODO add check for eof if necessary
                tokenizer = new StringTokenizer(
                        reader.readLine());
            }
            return tokenizer.nextToken();
        }

        static long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        static int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        static double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }
    }
}
