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.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Random;
import java.io.Writer;
import java.util.StringTokenizer;
import java.io.InputStream;

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

class PrimeSwaps {
    int n1 = 0;
    int[] l1 = null;
    int[] at = null;
    IntList primes = NumberTheoryZ.sieve( 100000 );
    IntList resLeft = new IntList(  );
    IntList resRight = new IntList(  );
    void swap(int i, int j){
        if (i > j){
            int t = j;
            j = i;
            i = t;
        }
        int val1 = l1[j];
        int val2 = l1[i];
        l1[i] = val1;
        l1[j] = val2;
        at[l1[i]] = i;
        at[l1[j]] = j;
        resLeft.add( i );
        resRight.add( j );
    }
    public int dist(int i, int j){
        return Math.abs(  i - j  ) + 1;
    }
    public void part(int dist){
        for (int e: primes){
            if (primes.binarySearch( dist - e ) >= 0){
                aa = e;
                bb = dist - e;
                break;
            }
        }
    }
    int aa = 0;
    int bb = 0;
    public void solve(int testNumber, InputReader in, OutputWriter out) {
        n1 = in.nextInt();
        l1 = new int[n1];
        at = new int[n1];
        for (int i = 0 ; i < n1; i++){
            l1[i] = in.nextInt() - 1;
            at[l1[i]] = i;
        }
        for (int i = 0 ; i < n1; i++){
//          DebugZ.print(l1);
            if (at[i] == i) continue;
            if (primes.binarySearch( dist(at[i], i) ) >= 0  || dist(at[i], i) == 1){
                swap(i, at[i]);
            }
            else {
                for (; ;){
                    if ((dist(at[i],i) + 1) % 2 == 0) break;
                    if (at[i] + 1 >= 0 && at[i] + 1 < n1){
                        swap(at[i], at[i] + 1);
                    }
                    else {
                        swap(at[i], at[i] - 1);
                    }
                }
                part((dist(at[i],i) + 1));
                swap(at[i] - (aa - 1), at[i]);
                swap(at[i] - (bb - 1), at[i]);
            }

        }
//      DebugZ.print(l1);

        out.printLine( resLeft.size() );
        for (int i = 0;  i< resLeft.size(); i++){
            out.printLine( resLeft.get( i )  + 1, resRight.get( i ) + 1 );
        }
    }
}

class IntList implements Iterable<Integer> {
    public int[] cont = null;
    public int size = 0;

    public IntList(int initialCapacity) {
        this.cont = new int[initialCapacity];
    }

    public IntList() {
        this(5);
    }

    public void add(int e) {
        if (size == cont.length) {
            cont = Arrays.copyOf(cont, ((cont.length << 1) - (cont.length >> 1) ) + 1);
        }
        cont[size++] = e;
    }

    public int get(int id) {
        if (id >= 0) return cont[id];
        else return cont[size + id];
    }

    public int binarySearch(int v1) {
        return Arrays.binarySearch(cont, 0, size, v1);
    }

    public String toString() {
        StringBuilder fin = new StringBuilder();
        fin.append('{');
        for (int i = 0; i < size; i++) {
            if (i != 0) fin.append(", ");
            fin.append(cont[i]);
        }
        fin.append('}');
        return fin.toString();
    }

    public int size() {
        return size;
    }

    public Iterator<Integer> iterator() {
        return new It();
    }

    public class It implements Iterator<Integer> {
        private int ptr = 0;

        public boolean hasNext() {
            if (ptr < size) return true;
            return false;
        }

        public Integer next() {
            return cont[ptr++];
        }

        public void remove() {

        }
    }
}

class NumberTheoryZ {

    public static IntList sieve(int n1) {
        IntList fin = new IntList();
        boolean[] l1 = new boolean[n1 + 1];
        int last = 0;
        for (int m = 2; m * m <= n1; m++) {
            if (!l1[m]) {
                fin.add(m);
                for (int k = m * m; k <= n1; k += m)
                    l1[k] = true;
            }
            last = m;
        }
        for (int m = last + 1; m <= n1; m++) {
            if (!l1[m])
                fin.add(m);
        }
        return fin;
    }
}

class InputReader {
    private BufferedReader in = null;
    private StringTokenizer st = null;

    public InputReader(InputStream usingStream) {
        in = new BufferedReader(new InputStreamReader(usingStream));

    }
    public String next(){
        for (;st == null || !st.hasMoreTokens();){
            String currentLine = null;
            try {
                currentLine = in.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (currentLine == null) return null;
            st = new StringTokenizer(currentLine);
        }
        return st.nextToken();
    }
    public int nextInt(){
        return Integer.parseInt(next());
    }
}

class OutputWriter {
    private PrintWriter usingPrintWriter = null;

    public OutputWriter(OutputStream usingStream){
        usingPrintWriter = new PrintWriter(usingStream);
    }
    public OutputWriter(Writer usingWriter){
        usingPrintWriter = new PrintWriter(usingWriter);
    }

    public void printLine(Object... l1){
        for (int i = 0;i < l1.length; i++){
            if (i != 0) usingPrintWriter.print(" ");
            usingPrintWriter.print(l1[i]);
        }
        usingPrintWriter.println();
    }
    public void flush(){
        usingPrintWriter.flush();
    }
    public void close(){
        flush();
        usingPrintWriter.close();
    }
}

