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

public class Main {
    static void sieve() {
        pLst = new ArrayList<Integer>();
        isPrime = new boolean[100001];
        Arrays.fill(isPrime, true);
        isPrime[0] = isPrime[1] = false;
        for(int i = 2; i * i < 100001; ++i) {
            if(isPrime[i]) {
                for(int j = i * i; j < 100001; j+=i)
                    isPrime[j] = false;
            }
        }
        for(int i = 0; i < 100001; i++)
            if(isPrime[i])
                pLst.add(i);
    }
    static boolean[] isPrime;
    static ArrayList<Integer> pLst;
    public static void solve() throws IOException {
        sieve();
        int n = nextInt();
        int[] a = new int[n];
        int[] pos = new int[n + 1];
        for(int i = 0; i < n; i++) {
            a[i] = nextInt();
            pos[a[i]] = i;
        }
        ArrayList<String> lst = new ArrayList<String>();
        for(int i = 1; i <= n; i++) {
            if(i == pos[i] + 1) continue;
            while(true) {
                int lo = 0, hi = pLst.size() - 1, ret = -1;
                while(lo <= hi) {
                    int mid = (lo + hi) >> 1;
                    if(pLst.get(mid) - 1 > pos[i] - i + 1)
                        hi = mid - 1;
                    else {
                        ret = mid;
                        lo = mid + 1;
                    }
                }
                if(ret == -1) break;
                if(pLst.get(ret) - 1 <= pos[i] - i + 1) {
                    int toPos = pos[i] - pLst.get(ret) + 1;
                    int toElem = a[toPos];
                    lst.add((toPos + 1) + " " + (pos[i] + 1));
                    pos[toElem] = pos[i];
                    a[pos[i]] = toElem;
                    pos[i] = toPos;
                    a[pos[i]] = i;
                }
            }
        }
        out.println(lst.size());
        for(String s : lst)
            out.println(s);
    }

    static BufferedReader br;
    static StringTokenizer st;
    static PrintWriter out;

    public static void main(String[] args) throws IOException {
        InputStream input = System.in;
        OutputStream output = System.out;
        br = new BufferedReader(new InputStreamReader(input));
        out = new PrintWriter(output);
        solve();
        out.close();
    }
    public static int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    public static double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
    public static String nextToken() throws IOException {
        while(st == null || !st.hasMoreTokens()) {
            String line = br.readLine();
            if(line == null) {
                return null;
            }
            st = new StringTokenizer(line);
        }
        return st.nextToken();
    }
}