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.*;
public class a {

    public static void main(String[] args) throws IOException {
        input.init(System.in);
        PrintWriter out = new PrintWriter(System.out);
        TreeSet<Integer> primes = new TreeSet<Integer>();
        boolean[] sieve = new boolean[100000];
        Arrays.fill(sieve, true);
        for(int i = 2; i<sieve.length; i++)
        {
            for(long j = (long)i*i; j<sieve.length; j+=i)
            {
                sieve[(int)j] = false;
            }
        }
        for(int i = 2; i<100000; i++)
            if(sieve[i])
                primes.add(i);
        int n = input.nextInt();
        int[] data = new int[n];
        int[] pos = new int[n];
        for(int i = 0; i<n; i++)
        {
            int a = input.nextInt()-1;
            data[i] = a;
            pos[a] = i;
        }
        ArrayList<Integer> as = new ArrayList<Integer>(), bs = new ArrayList<Integer>();
        for(int i = 0; i<n; i++)
        {
            int idx = pos[i];
            int diff = pos[i] - i;
            //System.out.println(i+" "+pos[i]);
            while(diff > 0)
            {
                int shift = primes.floor(diff+1) - 1;
                int other = pos[i] - shift;
                //System.out.println(shift+" "+other+" "+pos[i]);
                swap(data, pos, pos[i], other);
                //System.out.println(Arrays.toString(data)+" "+Arrays.toString(pos));
                as.add(idx+1);
                bs.add(other+1);
                idx = pos[i];
                diff = pos[i] - i;
            }
        }
        out.println(as.size());
        for(int i = 0; i<as.size(); i++)
        {
            int a = as.get(i), b = bs.get(i);
            if(a > b)
            {
                int temp = a; a = b; b = temp;
            }
            out.println(a+" "+b);
        }
        out.close();
    }
    static void swap(int[] data, int[] pos, int i, int j)
    {
        int posi = pos[data[i]];
        int posj = pos[data[j]];
        int datai = data[i];
        int dataj = data[j];
        data[i] = dataj;
        data[j] = datai;
        pos[data[j]] = posj;
        pos[data[i]] = posi;
    }
    public static class input {
        static BufferedReader reader;
        static StringTokenizer tokenizer;

        /** call this method to initialize reader for InputStream */
        static void init(InputStream input) {
            reader = new BufferedReader(
                         new InputStreamReader(input) );
            tokenizer = new StringTokenizer("");
        }

        /** get next word */
        static String next() throws IOException {
            while ( ! tokenizer.hasMoreTokens() ) {
                //TODO add check for eof if necessary
                tokenizer = new StringTokenizer(
                       reader.readLine() );
            }
            return tokenizer.nextToken();
        }

        static int nextInt() throws IOException {
            return Integer.parseInt( next() );
        }
        
        static double nextDouble() throws IOException {
            return Double.parseDouble( next() );
        }
        static long nextLong() throws IOException {
            return Long.parseLong( next() );
        }
    }
}
