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
/*
 *
 * @author Mukesh Singh
 *
 */

import java.io.*;
import java.util.*;
import java.text.DecimalFormat;
@SuppressWarnings("unchecked")
public class AB {	
	//solve test cases
	void solve() throws Exception {
		int n = in.nextInt() ;
		int[]pos = new int[n+1];
		int[]ar = new int[n+1];
		ar[0] = 0 ;
		pos[0] = 0 ;
		for(int i = 1 ; i <= n ; ++i ){
			ar[i]= in.nextInt();
			pos[ar[i]] = i ;
		}
		TreeSet<Integer> ts = new TreeSet<>();
		LinkedList<Node> ls = new LinkedList<Node>();
		for(int i=  1 ; i <= n ; ++i ) if(isPrime(i)) ts.add(i);
		for(int i = 1 ; i <= n ; ++i ){
			while( ar[i] != i ){
				int p = pos[i] ;
				int q = p-i+1 ;
				int  floor = ts.floor(q);
				int r = p - floor +1 ;
				//swap p and r
				ls.addLast(new Node(p,r));
				int t1 = ar[p] ; int t2 = ar[r] ;
				int p1 = pos[t1] ; int p2 = pos[t2] ;
				ar[p] = t2 ; ar[r] = t1 ;
				pos[t1] = p2 ; pos[t2] = p1 ;
			}
		}
		System.out.println(ls.size());
		for(Node nd : ls) System.out.println(Math.min(nd.a,nd.b)+" "+Math.max(nd.a,nd.b));
	}

	boolean isPrime(int n){
		if( n <= 3 ) return true ;
		for(int i = 2 ; i*i <= n ; ++i ) if(n%i == 0 ) return false ;
		return true ;
	}
		class Node{
		int a , b ;
		Node(int x , int y){
			a = x ;
			b = y ;
		}
	}
	//@ main function
	public static void main(String[] args) throws Exception {
		new AB();
	}
	
	InputReader in;
	PrintStream out ;
	DecimalFormat df ;
	AB() {
		try {
			File defaultInput = new File("file.in");
			if (defaultInput.exists()) 
				in = new InputReader("file.in");
			else 
				in = new InputReader();
			defaultInput = new File("file.out");
			if (defaultInput.exists()) 
				out = new PrintStream(new FileOutputStream("file.out"));
			else
				out = new PrintStream(System.out);
			df = new DecimalFormat("######0.00");
			solve();
			out.close();
		} 
		catch (Exception e) {
			e.printStackTrace();
			System.exit(261);
		}
	}
	
	class InputReader {
		BufferedReader reader;
		StringTokenizer tokenizer;
		
		InputReader() {
			reader = new BufferedReader(new InputStreamReader(System.in));
		}
		
		InputReader(String fileName) throws FileNotFoundException {
			reader = new BufferedReader(new FileReader(new File(fileName)));
		}
		
		String readLine() throws IOException {
			return reader.readLine();
		}
		
		String nextToken() throws IOException {
			while (tokenizer == null || !tokenizer.hasMoreTokens())
				tokenizer = new StringTokenizer(readLine());
			return tokenizer.nextToken();
		}
		
		boolean hasMoreTokens() throws IOException {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				String s = readLine();
				if (s == null)
					return false;
				tokenizer = new StringTokenizer(s);
			}
			return true;
		}
		
		int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(nextToken());
		}
		
		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(nextToken());
		}
		
		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(nextToken());
		}
	}
}
