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.FileNotFoundException;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.File;
import java.io.Writer;
import java.util.HashSet;
import java.util.List;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.FileReader;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.io.InputStream;

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

class TaskC {
    public void solve(int testNumber, FastScanner s, Output ww) {
        int n = 0;
        int[] a = {};
        try {
             n = s.nextInt();
            a = new int[n+1];
             for(int i=1;i<=n;i++) a[i] = s.nextInt();
        } catch (IOException e) {
            e.printStackTrace();
        }
        Number num = new Number();
        int[] prime = num.sieveEratosthenes(100000);
        HashSet<Integer> st = new HashSet<Integer>();
        for(int i=0;i<prime.length;i++) st.add(prime[i]);
        int[] prim = new int[100001];
        prim[1] = 2;
        prim[2] = 2;
        for(int i=3;i<=100000;i++){
            if(st.contains(i)) prim[i] = i;
            else prim[i] = prim[i-1];
        }

        int[] posix = new int[n+2];
        for(int i=1;i<=n;i++) posix[a[i]] = i;

        List<Pair> lt = new ArrayList<Pair>();

        for(int i=1;i<=n;i++){
            while(i != posix[i]){
                int pos = posix[i];
                int npos = pos - (prim[pos-i]-1);

                posix[a[pos]] = npos;
                posix[a[npos]] = pos;
                int tmp = a[pos];
                a[pos] = a[npos];
                a[npos] = tmp;

                lt.add(new Pair(npos,pos));
            }
        }

        ww.printLine(lt.size());
        for(Pair p : lt) ww.printLine(p.x+" "+p.y);

    }
    class Pair{
        int x;
        int y;
        public Pair(int x, int y){
            this.x = x;
            this.y = y;
        }
    }
}

class FastScanner {
    BufferedReader s;
    StringTokenizer st;

    public FastScanner(InputStream InputStream){
        st = new StringTokenizer("");
        s = new BufferedReader(new InputStreamReader(InputStream));
    }

    public FastScanner(File f) throws FileNotFoundException{
        st = new StringTokenizer("");
        s = new BufferedReader (new FileReader(f));
    }

    public int nextInt() throws IOException{
        if(st.hasMoreTokens())
            return Integer.parseInt(st.nextToken());
        else{
            st = new StringTokenizer(s.readLine());
            return nextInt();
        }
    }

}

class Output {

    private final PrintWriter writer;

    public Output(OutputStream outputStream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public Output(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void print(Object...objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }

    public void printLine(Object...objects) {
        print(objects);
        writer.println();
    }

    public void close() {
        writer.close();
    }


}

class Number {

    int[] sieveEratosthenes(int n) {
        if(n <= 32){
            int[] primes = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 };
            for(int i = 0;i < primes.length;i++){
                if(n < primes[i]){
                    return Arrays.copyOf(primes, i);
                }
            }
            return primes;
        }

        int u = n + 32;
        double lu = Math.log(u);
        int[] ret = new int[(int) (u / lu + u / lu / lu * 1.5)];
        ret[0] = 2;
        int pos = 1;

        int[] isp = new int[(n + 1) / 32 / 2 + 1];
        int sup = (n + 1) / 32 / 2 + 1;

        int[] tprimes = { 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 };
        for(int tp : tprimes){
            ret[pos++] = tp;
            int[] ptn = new int[tp];
            for(int i = (tp - 3) / 2;i < tp << 5;i += tp)
                ptn[i >> 5] |= 1 << (i & 31);
            for(int i = 0;i < tp;i++){
                for(int j = i;j < sup;j += tp)
                    isp[j] |= ptn[i];
            }
        }

        // 3,5,7
        // 2x+3=n
        int[] magic = { 0, 1, 23, 2, 29, 24, 19, 3, 30, 27, 25, 11, 20, 8, 4,
                13, 31, 22, 28, 18, 26, 10, 7, 12, 21, 17, 9, 6, 16, 5, 15, 14 };
        int h = n / 2;
        for(int i = 0;i < sup;i++){
            for(int j = ~isp[i];j != 0;j &= j - 1){
                int pp = i << 5 | magic[(j & -j) * 0x076be629 >>> 27];
                int p = 2 * pp + 3;
                if(p > n)
                    break;
                ret[pos++] = p;
                for(int q = pp;q <= h;q += p)
                    isp[q >> 5] |= 1 << (q & 31);
            }
        }

        return Arrays.copyOf(ret, pos);
    }


}
