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.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.util.Arrays;

public class Main {
	
	public static Reader in = new Reader();
	public static Writer out = new Writer();
	
	public static void main(String[] args) {
		int n = in.readInt();
		
		boolean[] isPrime = new boolean[n+1];
		
		Arrays.fill(isPrime, true);
		
		isPrime[0] = isPrime[1] = false;
		
		int max = (int)Math.sqrt(n);
		
		for(int i=2; i<=max; i++) if(isPrime[i]) {
			for(int j=i*2; j<isPrime.length; j+=i) {
				isPrime[j] = false;
			}
		}
		
		int[] closestPrime = new int[n+1];
		
		for(int i=2; i<isPrime.length; i++) if(isPrime[i]) {
			closestPrime[i] = i;
		}
	
		for(int i=3; i<=n; i++) {
			if(closestPrime[i]==0) {
				closestPrime[i] = closestPrime[i-1];
			}
		}
		
		//System.out.println(Arrays.toString(closestPrime));
		int[] a = new int[n];
		
		int[] pos = new int[n+1];
		
		for(int i=0; i<n; i++) {
			a[i] = in.readInt();
			pos[a[i]] = i;
		}
		
		StringBuffer ans = new StringBuffer();
		
		int k = 0;
		
		for(int i=1; i<=n; i++) {
			while(pos[i] > i-1) {
				int closest = closestPrime[pos[i] - (i-1) + 1];
				//System.out.println(i+" "+ pos[i] +" " + closest);
				int f = pos[i] - closest + 1;
				int s = pos[i];
				int temp = a[f];
				a[f] = a[s];
				a[s] = temp;
				pos[i] = f;
				pos[temp] = s;
				k++;
				ans.append(String.format("%d %d\n", f+1, s+1));
			}
		}
		
		out.println(k);
		out.println(ans);
		out.close();
	}
	
}

class Reader {
	
	private static final int SIZE = 1<<13;
	
	private static InputStream in = System.in;
	
	private int offSet;
	private int bufferSize;
	private byte[] buffer;
	
	private char[] charBuffer;
	
	public Reader() {
		buffer = new byte[SIZE];
		charBuffer = new char[SIZE];
	}
	
	public int readInt() {
		int number = 0;
		boolean neg = false;
		
		try {
			if(offSet == bufferSize) {
				offSet = 0;
				bufferSize = in.read(buffer);
			}
			
			for(; offSet < bufferSize && buffer[offSet] != '-' && buffer[offSet] < '0'; offSet++) {
				if(offSet == bufferSize-1) {
					offSet = -1;
					bufferSize = in.read(buffer);
				}
			}
			
			if(buffer[offSet] == '-') {
				neg = true;
				offSet++;
				if(offSet == bufferSize) {
					offSet = 0;
					bufferSize = in.read(buffer);
				}
			}
			
			for(; offSet < bufferSize && buffer[offSet] >= '0' && buffer[offSet] <= '9'; offSet++) {
				number = number * 10 - '0' + buffer[offSet];
				if(offSet == bufferSize-1) {
					offSet = -1;
					bufferSize = in.read(buffer);
				}
			}
			
			offSet++;
		} catch(IOException io) {
			io.printStackTrace();
			System.exit(0);
		}
		
		return neg ? -number : number;
	}
	
	public long readLong() {
		long number = 0;
		boolean neg = false;
		
		try {
			if(offSet == bufferSize) {
				offSet = 0;
				bufferSize = in.read(buffer);
			}
			
			for(; offSet < bufferSize && buffer[offSet] != '-' && buffer[offSet] < '0'; offSet++) {
				if(offSet == bufferSize-1) {
					offSet = -1;
					bufferSize = in.read(buffer);
				}
			}
			
			if(buffer[offSet] == '-') {
				neg = true;
				offSet++;
				if(offSet == bufferSize) {
					offSet = 0;
					bufferSize = in.read(buffer);
				}
			}
			
			for(; offSet < bufferSize && buffer[offSet] >= '0' && buffer[offSet] <= '9'; offSet++) {
				number = number * 10 - '0' + buffer[offSet];
				if(offSet == bufferSize-1) {
					offSet = -1;
					bufferSize = in.read(buffer);
				}
			}
			
			offSet++;
		} catch(IOException io) {
			io.printStackTrace();
			System.exit(0);
		}
		
		return neg ? -number : number;
	}
	
	public double readDouble() {
		return Double.parseDouble(readWord());
	}
	
	public String readLine() {
		StringBuffer sb = new StringBuffer();
		
		try {
			if(offSet == bufferSize) {
				offSet = 0;
				offSet = in.read(buffer);
			}
			
			for(; offSet < bufferSize && buffer[offSet] < ' '; offSet++) {
				if(offSet == bufferSize-1) {
					offSet = -1;
					bufferSize = in.read(buffer);
				}
			}
			
			if(bufferSize == -1) {
				return null;
			}
			
			int count = 0;
			
			for(; offSet < bufferSize && buffer[offSet] != '\r' && buffer[offSet] != '\n'; offSet++) {
				charBuffer[count] = (char)buffer[offSet];
				
				count++;
				
				if(count == SIZE) {
					count = 0;
					sb.append(charBuffer, 0, count);
				}
				
				if(offSet == bufferSize-1) {
					offSet = -1;
					bufferSize = in.read(buffer);
				}
			}
			
			offSet++;
			
			sb.append(charBuffer, 0, count);
		} catch(IOException io) {
			io.printStackTrace();
			System.exit(0);
		}
		
		return sb.toString();
	}
	
	public String readWord() {
		StringBuffer sb = new StringBuffer();
		
		try {
			if(offSet == bufferSize) {
				offSet = 0;
				offSet = in.read(buffer);
			}
			
			for(; offSet < bufferSize && buffer[offSet] < ' '; offSet++) {
				if(offSet == bufferSize-1) {
					offSet = -1;
					bufferSize = in.read(buffer);
				}
			}
			
			if(bufferSize == -1) {
				return null;
			}
			
			int count = 0;
			
			for(; offSet < bufferSize && buffer[offSet] != ' ' && buffer[offSet] != '\r' && buffer[offSet] != '\n'; offSet++) {
				charBuffer[count] = (char)buffer[offSet];
				
				count++;
				
				if(count == SIZE) {
					count = 0;
					sb.append(charBuffer, 0, count);
				}
				
				if(offSet == bufferSize-1) {
					offSet = -1;
					bufferSize = in.read(buffer);
				}
			}
			
			offSet++;
			
			sb.append(charBuffer, 0, count);
		} catch(IOException io) {
			io.printStackTrace();
			System.exit(0);
		}
		
		return sb.toString();
	}

	public char[] readWord(int n) {
		char[] word = new char[n];
		
		try {
			if(offSet == bufferSize) {
				offSet = 0;
				offSet = in.read(buffer);
			}
			
			for(; offSet < bufferSize && buffer[offSet] < ' '; offSet++) {
				if(offSet == bufferSize-1) {
					offSet = -1;
					bufferSize = in.read(buffer);
				}
			}
			
			if(bufferSize == -1) {
				return null;
			}
			
			for(int wi=0; offSet < bufferSize && buffer[offSet] != '\r' && buffer[offSet] != '\n'; offSet++) {
				word[wi++] = (char)buffer[offSet];
				
				if(offSet == bufferSize-1) {
					offSet = -1;
					bufferSize = in.read(buffer);
				}
			}
			
			offSet++;
		} catch(IOException io) {
			io.printStackTrace();
			System.exit(0);
		}
		
		return word;
	}

}

class Writer {
	
	private BufferedWriter output;
	
	public Writer() {
		output = new BufferedWriter(new OutputStreamWriter(System.out));
	}
	
	public void println() {
		try {
			output.append("\n");
		} catch(IOException io) { io.printStackTrace(); System.exit(0);}
	}

	public void print(Object o) {
		try {
			output.append(o.toString());
		} catch(IOException io) { io.printStackTrace(); System.exit(0);}
	}
	
	public void println(Object o) {
		try {
			output.append(o.toString()+"\n");
		} catch(IOException io) { io.printStackTrace(); System.exit(0);}
	}

	public void printf(String format, Object... args) {
		try {
			output.append(String.format(format, args));
		} catch(IOException io) { io.printStackTrace(); System.exit(0);}
	}
	
	public void printfln(String format, Object... args) {
		try {
			output.append(String.format(format, args)+"\n");
		} catch(IOException io) { io.printStackTrace(); System.exit(0);}
	}
	
	public void flush() {
		try {
			output.flush();
		} catch(IOException io) { io.printStackTrace(); System.exit(0);}
	}
	
	public void close() {
		try {
			output.close();
		} catch(IOException io) { io.printStackTrace(); System.exit(0);}
	}

}