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.*;
import java.util.ArrayList;


public class C {	
	BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter out;
    
	public void solve() throws IOException {
        int N = nextInt();
        int[] primes = getPrimeNumbers(N);
        int[] A = new int[N];
        int[] pos = new int[N];

        for (int i = 0; i < N; i++) {
            A[i] = nextInt() - 1;
            pos[A[i]] = i;
        }

        ArrayList<int[]> ans = new ArrayList<int[]>();
        for (int i = 0; i < N; i++) {
            int cur = pos[i];
            int tar = i;

            while (cur != tar) {
                int toswap = -1;
                if (tar > cur) {
                    int distance = tar - cur + 1;
                    int pr = getSmallerPrime(primes, distance);
                    toswap = cur + pr - 1;
                    ans.add(new int[]{cur, toswap});
                } else {
                    int distance = cur - tar + 1;
                    int pr = getSmallerPrime(primes, distance);
                    toswap = cur - pr + 1;
                    ans.add(new int[]{toswap, cur});
                }
//                out.println(cur + ", " + toswap);
                pos[A[cur]] = toswap;
                pos[A[toswap]] = cur;
                int tmp = A[cur]; A[cur] = A[toswap]; A[toswap] = tmp;
                cur = toswap;
            }
        }
        out.println(ans.size());
        for (int[] a: ans) {
            out.println( (a[0]+1) + " " + (a[1]+1));
        }
	}

    public int getSmallerPrime(int[] primes, int x) {
        int l = 0;
        int r = primes.length - 1;
        while (l < r) {
            int mid = (l + r + 1) / 2;
            if (primes[mid] == x) return primes[mid];

            if (primes[mid] > x) {
                r = mid - 1;
            } else {
                l = mid;
            }
        }
        return primes[l];
    }

    // prime numbers
    public int[] getPrimeNumbers(int max){
        boolean[] table = getPrimeTable(max);
        int size = 0;
        for(int i = 1; i <= max; i++){
            if(table[i]) size++;
        }
        int[] rets = new int[size];
        int current = 0;
        for(int i = 1; i <= max; i++){
            if(table[i]){
                rets[current++] = i;
            }
        }
        return rets;
    }
    public boolean[] getPrimeTable(int max){
        boolean[] isPrime = new boolean[max+1];
        for(int i = 2; i <= max; i++){
            isPrime[i] = true;
        }
        for(int i = 2; i <= max; i++){
            if(isPrime[i]){
                for(int j = i+i; j <= max; j+=i){
                    isPrime[j] = false;
                }
            }
        }
        return isPrime;
    }
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new C().run();
	}
	
	public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            out = new PrintWriter(System.out);
            solve();
            reader.close();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

}
