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 static java.lang.System.in;

import java.io.IOException;
import java.util.Arrays;


public class C246 {
    static byte[] buffer = new byte[8192];
    static int offset = 0;
    static int bufferSize = 0;
    
    
    public static void main(String args[])throws IOException
    {
        int sie[]= new int[100001];
        int primes[]= new int[100001];
        int pb[]= new int[100001];
        int eve[][]= new int [100001][2];
        int ans[][]= new int [500001][2];
        int num=0,l=0;;
        sie[1]=1;
        for (int i=2;i<=100000;i++)
        {
            if (sie[i]==0)
            {
                primes[l++]=i;
                //System.out.println(i);
                num++;
                
                for (int j=2*i;j<=100000;j+=i)
                    sie[j]=1;
            }
        }
        
        //System.out.println(num);
        int pr =-1;
        pr=-1;
        for (int i=2;i<=100000;i++)
        {
            if (sie[i]==0)
            {
                pb[i]= pr;
                pr = i;
            }
            else
                pb[i] = pr;
        }
        for (int i=4;i<=100000;i+=2)
            
        {
            
            int n1 =i;;
            while(true)
            {
                 n1 = pb[n1];
                
                if (sie[n1] ==0 && sie[i-n1]==0)
                {
                    //System.out.println(i+" "+(i-n1)+" "+n1);
                    eve[i][0] = n1;
                    eve[i][1]= i-n1;
                    
                    
                    break;
                }
                
            }
        }
    //  System.out.println(k1);
        int n = readInt();
        int arr[] = new int[n+1];
        int pos[]= new int[n+1];
        int pos1[]= new int[n+1];
        for (int i=1;i<=n;i++)
        {
            arr[i]= readInt();
            pos[i] = arr[i];
            pos1[arr[i]] = i;
        }
        //System.out.println(eve[12][0] +" "+eve[12][1]);
        Arrays.sort(arr);
        int k=0;
        /*for (int i=1;i<=n;i++)
        {
            System.out.println(i +" "+pos[i] +" "+pos1[i]);
        }*/
        for (int i=1;i<=n;i++)
        {
            int num1 = pos1[arr[i]]-i+1;
            //if (i<20)
            //System.out.println(i+" "+num1);
            if (num1<=1)
                continue;
            else
            {
                if (sie[num1]==0)
                {
                    int n1 = pos[i];
                    
                    ans[k][0] = pos1[arr[i]];
                    ans[k][1]= i;
                    k++;
                    int tmp1 = pos[i];
                    pos[i] = pos[pos1[arr[i]]];
                    pos[pos1[arr[i]]] = tmp1;
                    
                    pos1[n1] = pos1[arr[i]];
                    pos1[arr[i]] =i;
                    
                    
                }
                else
                {
                    if (num1%2!=0)
                        {
                        int pl = pos1[arr[i]]-1;
                        //if(i<20)
                            //System.out.println("    "+pl);
                         int n1 = pos[pl];
                        ans[k][0] = pos1[arr[i]];
                        ans[k][1]= pl;
                        k++;
                        int  tmp1 = pos[pl];
                        pos[pl] = pos[pos1[arr[i]]];
                        pos[pos1[arr[i]]] = tmp1;
                        
                        pos1[n1] = pos1[arr[i]];
                        pos1[arr[i]] =pl;
                        num1--;
                        }
                    int pl = pos1[arr[i]]-eve[num1][0]+1;
                    //if(i<20)
                    //System.out.println("    "+pl);
                    int n1 = pos[pl];
                    ans[k][0] = pos1[arr[i]];
                    ans[k][1]= pl;
                    k++;
                    int tmp1 = pos[pl];
                    pos[pl] = pos[pos1[arr[i]]];
                    pos[pos1[arr[i]]] = tmp1;
                    
                    pos1[n1] = pos1[arr[i]];
                    pos1[arr[i]] =pl;
                    
                    pl = pos1[arr[i]]-eve[num1][1]+1;
                    //if(i<20)
                        //System.out.println("    "+pl);
                     n1 = pos[pl];
                    ans[k][0] = pos1[arr[i]];
                    ans[k][1]= pl;
                    k++;
                     tmp1 = pos[pl];
                    pos[pl] = pos[pos1[arr[i]]];
                    pos[pos1[arr[i]]] = tmp1;
                    
                    pos1[n1] = pos1[arr[i]];
                    pos1[arr[i]] =pl;
                    
                    pl = pos1[arr[i]]-1;
                    //if(i<20)
                        //System.out.println("    "+pl);
                     n1 = pos[pl];
                    ans[k][0] = pos1[arr[i]];
                    ans[k][1]= pl;
                    k++;
                     tmp1 = pos[pl];
                    pos[pl] = pos[pos1[arr[i]]];
                    pos[pos1[arr[i]]] = tmp1;
                    
                    pos1[n1] = pos1[arr[i]];
                    pos1[arr[i]] =pl;
                    
                    
                    
                }
            }
        }
        
        System.out.println(k);
        for (int i=0;i<k;i++)
        {
            int n1  = ans[i][0]<ans[i][1]?ans[i][0]:ans[i][1];
            int n2 = ans[i][0]>ans[i][1]?ans[i][0]:ans[i][1];
            System.out.println(n1+" "+n2);
        }

    }
    static int readInt() throws IOException{
        int number = 0;
        int neg = 1;
        if(offset==bufferSize){
            offset = 0;
            bufferSize = in.read(buffer);
        }
        for(;buffer[offset]<0x30 || buffer[offset]=='-'; ++offset)
        {
            if (buffer[offset]=='-')
                neg = -1;
            if(offset==bufferSize-1){
                offset=-1;
                bufferSize = in.read(buffer);
            }
        }
        for(;offset<bufferSize && buffer[offset]>0x2f;++offset){
            number = number*0x0a+buffer[offset]-0x30;
            if(offset==bufferSize-1){
                offset = -1;
                bufferSize = in.read(buffer);
            }
        }
        ++offset;
        return number*neg;
    }

}
