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

import static java.lang.Math.abs;
import static java.lang.Math.max;
import static java.lang.Math.min;

public class PrimeSwaps implements Closeable {

  private InputReader in = new InputReader(System.in);
  private PrintWriter out = new PrintWriter(System.out);

  public void solve() {
    fill();
    int n = in.ni();
    x = new int[n];
    pos = new int[n];
    for (int i = 0; i < n; i++) {
      pos[x[i] = in.ni() - 1] = i;
    }
    for (int i = 0; i < n; i++) {
      while (pos[i] != i) {
        int to = pos[i];
        int dist = abs(i - to) + 1;
        if (prime[dist]) {
          swap(i, to);
        } else {
          if (i < to) {
            swap(pos[i], pos[i] - previous[dist - 1] + 1);
          } else {
            swap(pos[i], pos[i] + previous[dist - 1] - 1);
          }
        }
      }
    }
    out.println(swaps.size());
    for (int[] swap : swaps) {
      out.println((swap[0] + 1) + " " + (swap[1] + 1));
    }
  }

  private final int MAX_N = (int) 1e5;
  private int[] x, pos;
  private boolean[] prime = new boolean[MAX_N + 1];
  private int[] previous = new int[MAX_N + 1];

  private void fill() {
    Arrays.fill(prime, true);
    prime[0] = prime[1] = false;
    for (int i = 2; i <= MAX_N; i++) {
      if (prime[i]) {
        for (long j = (long) i * i; j <= MAX_N; j += i) {
          prime[(int) j] = false;
        }
      }
    }
    int prev = 1;
    for (int i = 2; i <= MAX_N; i++) {
      previous[i] = prev;
      if (prime[i]) {
        prev = i;
      }
    }
  }

  private List<int[]> swaps = new ArrayList<>();

  private void swap(int from, int to) {
    swaps.add(new int[]{min(from, to), max(from, to)});
    x[from] = x[to] ^ x[from] ^ (x[to] = x[from]);
    pos[x[from]] = pos[x[to]] ^ pos[x[from]] ^ (pos[x[to]] = pos[x[from]]);
  }

  @Override
  public void close() throws IOException {
    in.close();
    out.close();
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

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

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

    public void close() throws IOException {
      reader.close();
    }
  }

  public static void main(String[] args) throws IOException {
    try (PrimeSwaps instance = new PrimeSwaps()) {
      instance.solve();
    }
  }
}
