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.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

/**
 * @author Don Li
 */
public class PrimeSwaps {
    
    int n;
    int[] a, pos;
    
    boolean[] prime;
    int[] p;
    
    List<int[]> res = new ArrayList<>();
    
    void solve() {
        n = in.nextInt();
        a = new int[n];
        for (int i = 0; i < n; i++) a[i] = in.nextInt();
        
        prime = new boolean[n + 1];
        Arrays.fill(prime, true);
        prime[0] = prime[1] = false;
        int sqrt = (int) (Math.sqrt(n) + 0.5);
        for (int i = 0; i <= sqrt; i++) {
            if (prime[i]) {
                for (int j = i * i; j <= n; j += i) prime[j] = false;
            }
        }
        
        p = getPrimeList();
        
        
        pos = new int[n + 1];
        for (int i = 0; i < n; i++) pos[a[i]] = i;
        
        for (int i = 1; i <= n; i++) {
            int x = pos[i], y = i - 1;
            while (x != y) {
                int t = Math.abs(x - y) + 1;
                t = find(t);
                
                swap(x, x - t + 1);
                x = pos[i];
            }
        }
        
        out.println(res.size());
        for (int i = 0; i < res.size(); i++) {
            int[] x = res.get(i);
            out.printf("%d %d%n", x[0] + 1, x[1] + 1);
        }
    }
    
    int find(int k) {
        int lb = -1, ub = p.length;
        while (ub - lb > 1) {
            int m = (lb + ub) / 2;
            if (p[m] > k) ub = m;
            else lb = m;
        }
        return p[ub - 1];
    }
    
    void swap(int i, int j) {
        int tmp = a[i];
        a[i] = a[j];
        a[j] = tmp;
        
        pos[a[i]] = i;
        pos[a[j]] = j;
        
        res.add(new int[]{Math.min(i, j), Math.max(i, j)});
    }
    
    int[] getPrimeList() {
        int cnt = 0;
        for (int i = 0; i <= n; i++) if (prime[i]) cnt++;
        
        int[] res = new int[cnt];
        for (int i = 0, j = 0; i <= n; i++) if (prime[i]) res[j++] = i;
        return res;
    }
    
    public static void main(String[] args) {
        in = new FastScanner(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(System.out);
        new PrimeSwaps().solve();
        out.close();
    }
    
    static FastScanner in;
    static PrintWriter out;
    
    static class FastScanner {
        BufferedReader in;
        StringTokenizer st;
        
        public FastScanner(BufferedReader in) {
            this.in = in;
        }
        
        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        public int nextInt() {
            return Integer.parseInt(nextToken());
        }
        
        public long nextLong() {
            return Long.parseLong(nextToken());
        }
        
        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}
