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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.TreeMap;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.util.ArrayList;
import java.io.InputStream;

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

    static class c432 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            Integer[] aSort = new Integer[n];
            TreeMap<Integer, TreeSet<Integer>> pos = new TreeMap<>();
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
                if (!pos.containsKey(a[i])) {
                    pos.put(a[i], new TreeSet<>());
                }
                pos.get(a[i]).add(i);
                aSort[i] = a[i];
            }
            Arrays.sort(aSort);
            boolean[] comp = new boolean[n + 1];
            for (int i = 2; i <= n; i++) {
                if ((long) i * i > n) break;
                for (int j = i * i; j <= n; j += i) {
                    comp[j] = true;
                }
            }
            TreeSet<Integer> prime = new TreeSet<>();
            for (int i = 2; i <= n; i++) {
                if (!comp[i]) {
                    prime.add(i);
                }
            }
            ArrayList<String> ans = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                while (a[i] != aSort[i]) {
                    int swapPos = pos.get(aSort[i]).higher(i);
                    int len = prime.lower(swapPos - i + 2);
                    int newPos = swapPos - len + 1;
                    ans.add((newPos + 1) + " " + (swapPos + 1));
                    int tmp = a[newPos];
                    a[newPos] = a[swapPos];
                    a[swapPos] = tmp;
                    pos.get(aSort[i]).remove(swapPos);
                    pos.get(tmp).remove(newPos);
                    pos.get(tmp).add(swapPos);
                    pos.get(aSort[i]).add(newPos);
                }
            }
            out.println(ans.size());
            for (String cur : ans) out.println(cur);
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
        }

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

        public String next() {
            while (stt == null || !stt.hasMoreTokens()) {
                stt = new StringTokenizer(nextLine());
            }
            return stt.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

