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.util.*;
import java.io.*;

public class C
{

    Reader in;
    PrintWriter out;
    int i = 0, j = 0;
    BitSet primes;
    void solve()
    {
        
        //START// 
        int n = in.nextInt();
        int pr = 30;
        if (n > 30)
        {
            pr = n;
        }
        primes = new BitSet(pr+1);
        primes.set(2, pr, true);
        int limit = (int)Math.ceil(Math.sqrt(pr));
        for (i = 4; i <= pr; i += 2)
            primes.clear(i);
        int nextPrime = 3;
        while (nextPrime <= limit)
        {
            for (i = nextPrime * nextPrime; i <= pr; i+=nextPrime)
            {
                primes.clear(i);
            }
            nextPrime = primes.nextSetBit(nextPrime+1);
            if (nextPrime == -1)
                nextPrime = limit+1;
        }
        StringBuilder sb = new StringBuilder();
        int k = 0;
        int[] nums = new int[n+1];
        int[] pos = new int[n+1];
        for (i = 1; i <= n; i++)
        {
            nums[i] = in.nextInt();
            pos[nums[i]] = i;
        }
        for (i = 1; i <= n; i++)
        {
            while (nums[i] != i)
            {
                int startInd = pos[i];
                int tarInd = i;
                int dist = startInd - tarInd + 1;
                if (!primes.get(dist))
                {
                    int closest = primes.previousSetBit(dist);
                    int diff = dist - closest;
                    tarInd+=diff;
                }
                swap(pos, nums[startInd], nums[tarInd]);
                swap(nums, startInd, tarInd);
                sb.append(tarInd + " " + startInd);
                sb.append("\n");
                k++;
            }
        }
        out.println(k);
        if (k > 0)
            out.print(sb.toString());
        







        //END
        
    }
    void swap(int[] arr, int x, int y)
    {
        int tem = arr[x];
        arr[x] = arr[y];
        arr[y] = tem;
    }
    void runIO()
    {
        in = new Reader();
        out = new PrintWriter(System.out, false);
        solve();
        out.close();
    }

    public static void main(String[] args)
    {
        new C().runIO();
    }


    // input/output
    static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        

        public final String next()
        {
            int c = read();
            while (isSpaceChar(c))
            {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do
            {
                res.append((char) c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        private boolean isSpaceChar(int c)
        {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int nextInt()
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong()
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble()
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (c == '.')
                while ((c = read()) >= '0' && c <= '9')
                    ret += (c - '0') / (div *= 10);
            if (neg)
                return -ret;
            return ret;
        }

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

        public long[] readLongArray(int size)
        {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++)
                arr[i] = nextInt();
            return arr;
        }

        private void fillBuffer()
        {
            try
            {
                bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            }
            catch (IOException e)
            {

            }
            
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read()
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }
    }
}
