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.*;

public class cf432C {
    static class Num implements Comparable<Num> {
        int num;
        int index;
        public Num(int n, int i) {
            num = n;
            index = i;
        }
        public int compareTo(Num n) {
            return num - n.num;
        }
    }

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        int[] arrI = new int[n];
        Num[] arrSort = new Num[n];
        for(int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
            arrSort[i] = new Num(arr[i], i);
        }




        ArrayList<Integer> primes = new ArrayList<Integer>();
        int[] sieve = new int[n+2];
        for(int i = 2; i <= n+1; i++) {
            if(sieve[i] == 0) {
                primes.add(i);
                for(int j = i*2; j <= n+1; j+=i) {
                    sieve[j]++;
                }
            }
        }

        int[] primesArr = new int[primes.size()];
        for(int i = 0; i < primes.size(); i++) {
            primesArr[i] = primes.get(i);
        }

        int curr = 0;
        int count = 0;

        StringBuilder sb = new StringBuilder();

        Arrays.sort(arrSort);
        for(int i = 0; i < n; i++) {
            arrI[arrSort[i].index] = i;
        }
        
        int i = 0;
        while(i < n) {
            int index = arrSort[i].index;
            int start = i;
            if(index == start) {
                i++;
                continue;
            }
            while(index != start) {
                //System.out.println(index + " " + start);
                //printArray(arr);
                for(int j = start; j < index; j++) {
                    //System.out.println(curr + " " + index);
                    int num = index - j + 1;
                    //System.out.println(num);
                    if(Arrays.binarySearch(primesArr, num) >= 0) {
                        int temp = arr[index];
                        arr[index] = arr[j];
                        arr[j] = temp;
                        temp = arrI[index];
                        arrI[index] = arrI[j];
                        arrI[j] = temp;

                        arrSort[arrI[j]].index = j;
                        arrSort[arrI[index]].index = index;

                        count++;
                        sb.append((j+1) + " " + (index+1) + "\n");
                        //System.out.println((i+1) + " " + (index+1));
                        index = j;
                        break;
                    }
                }
            }
        }

        // while(curr < n) {
        //  int min = indexOf(arr, curr, arrSort[curr]);

        //  while(min != curr) {
        //      for(int i = curr; i < min; i++) {
        //          //System.out.println(curr + " " + min);
        //          int num = min - i + 1;
        //          //System.out.println(num);
        //          if(Arrays.binarySearch(primesArr, num) >= 0) {
        //              int temp = arr[min];
        //              arr[min] = arr[i];
        //              arr[i] = temp;
        //              count++;
        //              sb.append((i+1) + " " + (min+1) + "\n");
        //              //System.out.println((i+1) + " " + (min+1));
        //              min = i;
        //              break;
        //          }
        //      }
        //  }
        //  curr++;
        // }


        // while(curr != n) {
        //  int min = findMin(curr, arr.length-1, arr)[1];
        //  //System.out.println(curr + " " + min);
        //  if(min == curr) {
        //      curr++;
        //      continue;
        //  }
        //  while(min != curr) {
        //      for(int i = curr; i < min; i++) {
        //          //System.out.println(curr + " " + min);
        //          int num = min - i + 1;
        //          //System.out.println(num);
        //          if(Arrays.binarySearch(primesArr, num) >= 0) {
        //              int temp = arr[min];
        //              arr[min] = arr[i];
        //              arr[i] = temp;
        //              count++;
        //              sb.append((i+1) + " " + (min+1) + "\n");
        //              //System.out.println((i+1) + " " + (min+1));
        //              min = i;
        //              break;
        //          }
        //      }
        //  }
        // }
        System.out.println(count);
        System.out.print(sb.toString());


    }

    public static int indexOf(int[] arr, int curr, int a) {
        for(int i = curr; i < arr.length; i++) {
            if(arr[i] == a) {
                return i;
            }
        }
        return -1;
    }

    public static void printArray(int[] arr) {
        for(int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println();
    }

    public static int findMinIndex(int curr, int[] arr) {
        int min = Integer.MAX_VALUE;
        int minIndex = curr;
        for(int i = curr; i < arr.length; i++) {
            if(arr[i] < min) {
                min = arr[i];
                minIndex = i;
            }
        }
        return minIndex;
    }

    public static int[] findMin(int curr, int to, int[] arr) {
        if(curr == to)
            return new int[]{arr[curr], curr};
        int mid = curr + (to-curr)/2;
        int[] first = findMin(curr, mid, arr);
        int[] sec = findMin(mid+1, to, arr);
        if(first[0] < sec[0])
            return first;
        return sec;
        //return Math.min(, );
    }

    public static int findMin(int curr, int[] arr) {
        int last = 0;
        int minIndex = curr;
        for(int i = curr; i < arr.length; i++) {
            if(arr[i] < last) {
                minIndex = i;
                return minIndex;
            }
            last = arr[i];
        }
        return -1;
    }
}