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.BufferedInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.Queue;
import java.util.Set;
import java.util.Stack;
import java.util.TreeSet;

public class Main
{
	private final int SIZEN = 100000;
	
	public void swap(int[] a, int[] pos, ArrayList<int[]> arr, int i, int j)
	{
		pos[a[i]] = j;
		pos[a[j]] = i;
		int tmp = a[i];
		a[i] = a[j];
		a[j] = tmp;
		arr.add(new int[]{i, j});
	}
	
	public void foo()
	{
		MyScanner scan = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		boolean[] isPrime = new boolean[SIZEN + 1];
		Arrays.fill(isPrime, true);
		ArrayList<Integer> primes = new ArrayList<Integer>();
		for(int i = 2;i <= SIZEN;++i)
		{
			if(isPrime[i])
			{
				primes.add(i);
				for(int j = 2 * i;j <= SIZEN;j += i)
				{
					isPrime[j] = false;
				}
			}
		}
		int[] table = new int[SIZEN + 1];
		for(int i = 4;i <= SIZEN;i += 2)
		{
			for(int j : primes)
			{
				if(isPrime[i - j])
				{
					table[i] = j;
					break;
				}
			}
		}
		int n = scan.nextInt();
		int[] a = new int[n + 1];
		int[] pos = new int[n + 1];
		for(int i = 1;i <= n;++i)
		{
			a[i] = scan.nextInt();
			pos[a[i]] = i;
		}
		ArrayList<int[]> arr = new ArrayList<int[]>();
		for(int i = 1;i <= n;++i)
		{
			if(a[i] == i)
			{
				continue;
			}
			int j = pos[i];
			if(isPrime[j - i + 1])
			{
				swap(a, pos, arr, i, j);
			}
			else
			{
				if(0 == (j - i + 1) % 2)
				{
					swap(a, pos, arr, j - 1, j);
					--j;
				}
				int k = j - table[j - i + 2] + 1;
				swap(a, pos, arr, k, j);
				swap(a, pos, arr, i, k);
			}
		}
		out.println(arr.size());
		for(int[] ans : arr)
		{
			out.println(ans[0] + " " + ans[1]);
		}
		out.close();
	}

	public static void main(String[] args)
	{
		new Main().foo();
	}
	
	class MyScanner
	{
	    private byte[] buf = new byte[1024];
	    private int curChar;
	    private int numChars;
	    BufferedInputStream bis = new BufferedInputStream(System.in);

	    public int read() 
	    {
	        if (-1 == numChars)
	        {
	        	throw new InputMismatchException();
	        }
	        if (curChar >= numChars)
	        {
	            curChar = 0;
	            try 
	            {
	                numChars = bis.read(buf);
	            }
	            catch (IOException e)
	            {
	                throw new InputMismatchException();
	            }
	            if (numChars <= 0)
	            {
	            	return -1;
	            }
	        }
	        return buf[curChar++];
	    }

	    public int nextInt() 
	    {
	        int c = read();
	        while (isSpaceChar(c))
	        {
	        	c = read();
	        }
	        int sgn = 1;
	        if (c == '-') 
	        {
	            sgn = -1;
	            c = read();
	        }
	        int res = 0;
	        do 
	        {
	            if (c < '0' || c > '9')
	            {
	            	throw new InputMismatchException();
	            }
	            res *= 10;
	            res += c - '0';
	            c = read();
	        } while (!isSpaceChar(c));
	        return res * sgn;
	    }
	    
	    public long nextLong() 
	    {
	    	int c = read();
	    	while (isSpaceChar(c))
	    	{
	    		c = read();
	    	}
	    	int sgn = 1;
	    	if (c == '-') 
	    	{
	    		sgn = -1;
	    		c = read();
	    	}
	    	long res = 0;
	    	do 
	    	{
	    		if (c < '0' || c > '9')
	    		{
	    			throw new InputMismatchException();
	    		}
	    		res *= 10;
	    		res += c - '0';
	    		c = read();
	    	} while (!isSpaceChar(c));
	    	return res * sgn;
	    }
	    
	    public String next()
	    {
	        int c = read();
	        while (isSpaceChar(c))
	        {
	        	c = read();
	        }
	        StringBuilder res = new StringBuilder();
	        do 
	        {
	            res.appendCodePoint(c);
	            c = read();
	        } while (!isSpaceChar(c));
	        return res.toString();
	    }

	    private boolean isSpaceChar(int c) 
	    {
	        return ' ' == c || '\n' == c || '\r' == c || '\t' == c || -1 == c;
	    }
	}
}