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.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;

/**
 *
 *
 * 10 5 8 1 10 3 6 2 9 7 4 4 2 6 3 1 9 10 5 8 7
 *
 * @author pttrung
 */
public class C {

    //   public static long x, y, gcd;
    public static int Mod = 1000000007;
    public static PrintWriter out;
    public static ArrayList<Integer> re = new ArrayList();

    public static void main(String[] args) throws FileNotFoundException {
        Scanner in = new Scanner();
        out = new PrintWriter(System.out);
        //   System.out.println(Integer.MAX_VALUE);
        //PrintWriter out = new PrintWriter(new FileOutputStream(new File("output.txt")));
        int n = in.nextInt();
        Entry[] data = new Entry[n];
        TreeSet<Integer> set = new TreeSet();
        PriorityQueue<Entry> q = new PriorityQueue();
        boolean[] p = new boolean[n + 1];
        for (int i = 2; i < p.length; i++) {
            if (!p[i]) {
                set.add(i);
                for (long j = i + i; j < p.length; j += i) {
                    p[(int) j] = true;
                }
            }
        }
        for (int i = 0; i < n; i++) {
            data[i] = new Entry(i, in.nextInt());
            q.add(data[i]);
        }
        int index = 0;
        int result = 0;
        StringBuilder builder = new StringBuilder();
        while (!q.isEmpty()) {
            Entry e = q.poll();
            if (e.index == index) {
                
            } else {
                while(e.index != index){
                    result++;
                    int l = e.index - index + 1;
                    int step = set.floor(l);
                    int other = e.index - step + 1;
                    builder.append(other + 1).append(" ").append(e.index + 1).append("\n");
                    int tmp = e.index;
                    data[other].index = e.index;
                    e.index = other;
                    Entry a = data[other];
                    data[other] = e;
                    data[tmp] = a;
                }
             }
                index++;
        }
        out.println(result);
        out.println(builder.toString());
    

    out.close ();
}

public static class Entry implements Comparable<Entry> {

    int index, val;

    public Entry(int index, int val) {
        this.index = index;
        this.val = val;
    }

    @Override
    public int compareTo(Entry o) {
        return val - o.val;
    }
}
public static long pow(long a, long b) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2);
        if (b % 2 == 0) {
            return val * val;
        } else {
            return val * val * a;
        }
    }

    public static int gcd(int a, int b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    

}

    public static class Point implements Comparable<Point> {

    int x, y;

    public Point(int x, int y) {
        this.x = x;
        this.y = y;
    }

    @Override
    public int compareTo(Point o) {
        if (x != o.x) {
            return x - o.x;
        } else {
            return y - o.y;
        }
    }
}
//    public static void extendEuclid(long a, long b) {
//        if (b == 0) {
//            x = 1;
//            y = 0;
//            gcd = a;
//            return;
//        }
//        extendEuclid(b, a % b);
//        long x1 = y;
//        long y1 = x - (a / b) * y;
//        x = x1;
//        y = y1;
//
//    }

public static class FT {

    int[] data;

    FT(int n) {
        data = new int[n];
    }

    public void update(int index, int value) {
        while (index < data.length) {
            data[index] += value;
            index += (index & (-index));
        }
    }

    public int get(int index) {
        int result = 0;
        while (index > 0) {
            result += data[index];
            index -= (index & (-index));
        }
        return result;

    }
}

static class Scanner {

    BufferedReader br;
    StringTokenizer st;

    public Scanner() throws FileNotFoundException {
        // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
        br = new BufferedReader(new InputStreamReader(System.in));
        //br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
    }

    public String next() {

        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
        return st.nextToken();
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

    public String nextLine() {
        st = null;
        try {
            return br.readLine();
        } catch (Exception e) {
            throw new RuntimeException();
        }
    }

    public boolean endLine() {
        try {
            String next = br.readLine();
            while (next != null && next.trim().isEmpty()) {
                next = br.readLine();
            }
            if (next == null) {
                return true;
            }
            st = new StringTokenizer(next);
            return st.hasMoreTokens();
        } catch (Exception e) {
            throw new RuntimeException();
        }
    }
}
}
