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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author darinflar
 */
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);
		CF246C solver = new CF246C();
		solver.solve(1, in, out);
		out.close();
	}
}

class CF246C {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
        int n = in.readInt();
        //Random rnd = new Random(179);
        int[] a = in.readIntArray(n);
        for (int i = 0; i < n; i++)
            a[i]--;
        int[] cur = a.clone();
        int[] pos = new int[n];
        Arrays.sort(a);
        for (int i = 0; i < n; i++)
            pos[a[i]] = i;
        a = cur;
        int[] swap = new int[n + 101], parent = new int[n + 101];
        Arrays.fill(swap, (int) 1e9);
        Arrays.fill(parent, -1);
        swap[0] = 0;
        for (int i = 2; i <= n + 100; i++){
            if (!isPrime(i))
                continue;
            for (int j = 0; i + j - 1 <= n + 100; j++)
                if (swap[i + j - 1] > swap[j] + 1){
                    swap[i + j - 1] = swap[j] + 1;
                    parent[i + j - 1] = i - 1;
                }
        }
        ArrayList<Integer> first = new ArrayList<>(), second = new ArrayList<>();
        for (int i = 0; i < n; i++)
            while (pos[a[i]] < i)
                performSwap(a, i, i - pos[a[i]], parent, first, second);
        out.printLine(first.size());
        for (int i = 0; i < first.size(); i++)
            out.printLine(first.get(i), ' ', second.get(i));
    }

    void performSwap(int[] a, int i, int delta, int[] parent, ArrayList<Integer> f, ArrayList<Integer> s){
        if (delta == 0)
            return ;
        int curDelta = parent[delta];
        int j = i - curDelta;
        int y = a[i]; a[i] = a[j]; a[j] = y;
        f.add(j + 1); s.add(i + 1);
        performSwap(a, j, delta - curDelta, parent, f, s);
        if (delta - curDelta == 0)
            return ;
        y = a[i]; a[i] = a[j]; a[j] = y;
        f.add(j + 1); s.add(i + 1);
    }

    boolean isPrime(int n){
        if (n == 1)
            return false;
        for (int i = 2; i * i <= n; i++)
            if (n % i == 0)
                return false;
        return true;
    }
}

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

    public InputReader(Reader in){
        reader = new BufferedReader(in);
    }

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

    public String readWord(){
        while (tokenizer == null || !tokenizer.hasMoreTokens())
            tokenizer = new StringTokenizer(readLine());
        return tokenizer.nextToken();
    }

    public int readInt(){
        return Integer.parseInt(readWord());
    }

    public int[] readIntArray(int size){
        int[] result = new int[size];
        for (int i = 0; i < size; i++)
            result[i] = readInt();
        return result;
    }

    private BufferedReader reader;
    private StringTokenizer tokenizer;
}

class OutputWriter {
    public OutputWriter(PrintWriter writer) {
        this.writer = writer;
    }

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

    public OutputWriter(Writer out){
        writer = new PrintWriter(out);
    }

    public void print(Object...args){
        int size = args.length;
        for (int i = 0; i < size; i++)
            writer.print(args[i]);
    }

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

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

    private PrintWriter writer;
}

