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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class C {
    static int[] numbers;
    static int[] index;
    static boolean[] pr = primes();
    static List<int[]> operations = new ArrayList<>();

    static void move(int i, int j) {
        if (i != j) {
            if (i > j) move(j, i);
            else {
                for (int ii = i; ii < j; ii++) {
                    if (pr[j - ii + 1]) {
                        swap(ii, j);
                        operations.add(new int[] { ii, j });
                        move(i, ii);
                        return;
                    }
                }
            }
        }
    }

    static void swap(int i, int j) {
        int temp = numbers[i];
        numbers[i] = numbers[j];
        numbers[j] = temp;

        temp = index[numbers[j]];
        index[numbers[j]] = index[numbers[i]];
        index[numbers[i]] = temp;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String s = reader.readLine();

        int n = Integer.parseInt(s);

        String[] ss = reader.readLine().split(" ");
        numbers = new int[n];
        index = new int[n];
        for (int i = 0; i < ss.length; i++) {
            numbers[i] = Integer.parseInt(ss[i]) - 1;
            index[numbers[i]] = i;
        }

        for (int i = 0; i < n; i++) {
            move(index[i], i);
        }

        System.out.println(operations.size());
        for (int[] operation : operations) {
            System.out.println((operation[0] + 1) + " " + (operation[1] + 1));
        }
    }

    private static boolean[] primes() {
        boolean [] pr = new boolean[100001];
        Arrays.fill(pr, true);

        pr[0] = false;
        pr[1] = false;

        for (int i = 2; i < pr.length; i++) {
            if (pr[i]) {
                for (long j = 2 * i; j < pr.length; j += i)
                    pr[(int) j] = false;
            }
        }

        return pr;
    }

    private static int[] splitEven(int even) {
        if (pr[even]) return new int[]{ even };
        else {
            for (int i = 2; i < even; i++) {
                if (pr[i] && pr[even - i]) return new int[] { i, even - i };
            }

            return new int[0];
        }
    }

    private static int[] splitOdd(int odd) {
        if (pr[odd]) return new int[]{ odd };
        else {
            for (int i = odd - 1; i >= 2; i--)
                if (pr[i]) {
                    int[] split = splitEven(odd - i);
                    int[] res = new int[split.length + 1];
                    res[0] = odd - i;
                    System.arraycopy(split, 0, res, 1, split.length);
                    return res;
                }

            return new int[0];
        }
    }

    private static void quicksort(int low, int high) {
        int i = low, j = high;
        int pivot = numbers[low + (high-low)/2];
        while (i <= j) {
            while (numbers[i] < pivot) {
                i++;
            }
            while (numbers[j] > pivot) {
                j--;
            }

            if (i <= j) {
                exchange(i, j);
                i++;
                j--;
            }
        }
        if (low < j) quicksort(low, j);
        if (i < high) quicksort(i, high);
    }

    private static void exchange(int i, int j) {
        int temp = numbers[i];
        numbers[i] = numbers[j];
        numbers[j] = temp;

        int diff = j - i + 1;
        int[] split;
        if (diff % 2 == 0) split = splitEven(diff);
        else split = splitOdd(diff);

        if (split.length > 1) {
            if (diff % 2 == 0) split = splitOdd(diff + 1);
            else split = splitEven(diff + 1);

            if (split.length != 2) {
                if (diff % 2 == 0) split = splitEven(diff + 2);
                else split = splitOdd(diff + 2);

                if (split.length != 3) {
                    System.out.println("No solution");
                }
            }
        }

        switch (split.length) {
            case 0: break;
            case 1: operations.add(new int[] { i , j }); break;
            case 2:
                operations.add(new int[] { i, (i + split[0] - 1) });
                operations.add(new int[] { (i + split[0] - 1),j });
                operations.add(new int[] { i, (i + split[0] - 1) });
                break;
            case 3:
                operations.add(new int[] { i, (i + split[0] - 1) });
                operations.add(new int[] { (i + split[0] - 1),(i + split[0] - 1 + split[1] - 1) });
                operations.add(new int[] { (i + split[0] - 1 + split[1] - 1), j });
                operations.add(new int[] { (i + split[0] - 1), (i + split[0] - 1 + split[1] - 1) });
                operations.add(new int[] { i, (i + split[0] - 1) });
                break;
        }
    }
}
