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 Main implements Runnable{
    boolean prime[];
    TreeSet<Integer> primeSet;
    void sieve(){
        prime=new boolean[maxn+1];
        Arrays.fill(prime,true);
        for(int i=2;i*i<=maxn;i++){
            if(prime[i]==false)
                continue;
            for(int j=i*i;j<=maxn;j+=i)
                prime[j]=false;
        }
        primeSet=new TreeSet<>();
        for(int i=2;i<=maxn;i++)
            if(prime[i])
                primeSet.add(i);
    }
    private void solve()throws IOException{
        sieve();
        int n=nextInt();
        int a[]=new int[n+1];
        int elem[]=new int[n+1];
        for(int i=1;i<=n;i++){
            elem[i]=nextInt();
            a[elem[i]]=i;
        }
        ArrayList<Pair> list=new ArrayList<>();
        for(int i=1;i<=n;i++){
            while(a[i]!=i){
                int diff=a[i]-i+1;
                int j=prime[diff]?diff:primeSet.lower(diff);
                int y=a[i]-j+1;
                int x=a[i];
                list.add(new Pair(y,x));
                a[elem[y]]=x;
                a[elem[x]]=y;
                int temp=elem[y];
                elem[y]=elem[x];
                elem[x]=temp;
            }            
        }
        out.println(list.size());
        for(Pair p:list)
            out.println(p.first+" "+p.second);
    }
    class Pair{
        int first,second;
        Pair(int a,int b){
            first=a;
            second=b;
        }
    }

     
    ///////////////////////////////////////////////////////////

    final long mod=(long)(1e9+7);
    final int inf=(int)(1e9+1);
    final int maxn=(int)(1e5);
    final long lim=(long)(1e18);

    public void run(){
        try{
            br=new BufferedReader(new InputStreamReader(System.in));
            st=null;
            out=new PrintWriter(System.out);

            solve();

            // int t=nextInt();
            // for(int i=1;i<=t;i++){
            //     // out.print("Case #"+i+": ");
            //     solve();
            // }

            br.close();
            out.close();
        }catch(Exception e){
            e.printStackTrace();
            System.exit(1);
        }
    }
    public static void main(String args[])throws IOException{
        new Main().run();
    } 
    int max(int ... a){
        int ret=a[0];
        for(int i=1;i<a.length;i++)
        ret=Math.max(ret,a[i]);
        return ret;
    }
    int min(int ... a){
        int ret=a[0];
        for(int i=1;i<a.length;i++)
        ret=Math.min(ret,a[i]);
        return ret;
    }
    void debug(Object ... a){
        System.out.print("> ");
        for(int i=0;i<a.length;i++)
        System.out.print(a[i]+" ");
        System.out.println();
    }
    void debug(int a[]){debuga(Arrays.stream(a).boxed().toArray());}
    void debug(long a[]){debuga(Arrays.stream(a).boxed().toArray());}
    void debuga(Object a[]){
        System.out.print("> ");
        for(int i=0;i<a.length;i++)
        System.out.print(a[i]+" ");
        System.out.println();
    }
    BufferedReader br;
    StringTokenizer st;
    PrintWriter out;
    String nextToken()throws IOException{
        while(st==null || !st.hasMoreTokens())
        st=new StringTokenizer(br.readLine());
        return st.nextToken();
    }
    String nextLine()throws IOException{
        return br.readLine();
    }
    int nextInt()throws IOException{
        return Integer.parseInt(nextToken());
    }
    long nextLong()throws IOException{
        return Long.parseLong(nextToken());
    }
    double nextDouble()throws IOException{
        return Double.parseDouble(nextToken());
    }
}