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 {
  final boolean isFileIO = false; 
  BufferedReader in;
  PrintWriter out;
  StringTokenizer st = new StringTokenizer("");
  String delim = " ";

  public static void main(String[] args) {
    new Thread(null, new Main(), "", 268435456).start(); 
  }

  public void run() {
    try {
      initIO();
      solve();
      out.close();
    } catch(Exception e) {
      e.printStackTrace(System.err);
      System.exit(-1);
    }
  }

  public void initIO() throws IOException {
    if(!isFileIO) {
      in = new BufferedReader(new InputStreamReader(System.in));
      out = new PrintWriter(System.out);
    } else {
      in = new BufferedReader(new FileReader("input.txt"));
      out = new PrintWriter("output.txt"); 
    }
  }
  
  String nextToken() throws IOException {
    if(!st.hasMoreTokens()) {
      st = new StringTokenizer(in.readLine());
    }
    return st.nextToken(delim);
  }
 
  String readLine() throws IOException {
    return in.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());
  }

  class Number implements Comparable<Number> {
    public int val, pos, prev;

    public Number(int v, int p, int n) {
      this.val = v;
      this.pos = p;
      this.prev = n;
    }
    
    public int compareTo(Number y) {
      if(this.val > y.val) return 1;
      if(this.val < y.val) return -1;
      return 0;
    }
  }  

  void solve() throws IOException {
    int n = nextInt();
    boolean[] prime = new boolean[n + 1];
    prime[0] = prime[1] = true;
    for(int i = 2; i * i <= n; i++) {
      if(!prime[i])
        for(int j = i * i; j <= n; j += i) {
          prime[j] = true;
        }
    }
    int[] min = new int[n + 1];
    int m = 2;
    for(int i = 0; i <= n; i++) {
      if(!prime[i])
        m = i;
      min[i] = m;
    }
    Number[] num = new Number[n];
    for(int i = 0; i < n; i++) {
      num[i] = new Number(nextInt(), i, i);
    }
    Arrays.sort(num);
    int[] pos = new int[n];
    for(int i = 0; i < n; i++)
      pos[num[i].prev] = i;
    int ans = 0;
    ArrayList<Integer> ansx = new ArrayList<Integer>();
    ArrayList<Integer> ansy = new ArrayList<Integer>();
    for(int i = 0; i < n; i++) {
      int dist = num[i].pos + 1 - num[i].val;
      while(dist > 0) {
        int min_prime = min[dist];
        //out.println(dist + " " + num[i].val + " " + min_prime + " " +num[i].pos);
        //out.flush();
        int prev = pos[num[i].pos - min_prime + 1];
        num[prev].pos = num[i].pos;
        pos[num[i].pos] = prev;
        pos[num[i].pos - min_prime + 1] = i;
        ans++;
        ansy.add(num[i].pos + 1);
        ansx.add(num[i].pos - min_prime + 2);
        dist -= min_prime - 1;
        num[i].pos -= min_prime - 1;
      }
    }
    out.println(ans);
    for(int i = 0; i < ans; i++)
      out.println(ansx.get(i) + " " + ansy.get(i));
  }
    
}
