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.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	static TreeSet<Integer> primes;
	static int[] isComposite;

	static void sieve(int N)
	{
		isComposite = new int[N+1];					
		isComposite[0] = isComposite[1] = 1;		
		primes = new TreeSet<Integer>();

		for (int i = 2; i <= N; ++i) 					 
			if (isComposite[i] == 0) 					
			{
				primes.add(i);
				if(1l * i * i <= N)
					for (int j = i * i; j <= N; j += i)	
						isComposite[j] = 1;
			}   
	}
 
	public static void main(String[] args) throws Throwable {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), a[] = sc.nexIntArray();
		sieve(n<<1);
		StringBuilder sb = new StringBuilder();
		int ans = 0;
		
		for (int i = 0; i < n; i++) 
		{
			int pos = i , target = a[i]-1;
			while(pos!=target)
			{
				int dist = target-pos+1;
				int nxt = pos + primes.floor(dist)-1;
				sb.append((pos+1)+" "+(nxt+1)+"\n");
				a[pos] ^= a[nxt];
				a[nxt] ^= a[pos];
				a[pos] ^= a[nxt];
				pos = nxt;
				++ans;
			}
			if(a[i]-1!=i)--i;
		}
		
		System.out.println(ans);
		System.out.println(sb);		
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;
		public Scanner(InputStream s) {br = new BufferedReader(new InputStreamReader(s));}
		public Scanner(String file) throws FileNotFoundException {br = new BufferedReader(new FileReader(file));}
		public String next() throws IOException {while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();}
		public int nextInt() throws IOException {return Integer.parseInt(next());}
		public long nextLong() throws IOException {return Long.parseLong(next());}
		public String nextLine() throws IOException {return br.readLine();}
		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}
		public int[] nexIntArray() throws Throwable {
			st = new StringTokenizer(br.readLine());
			int[] a = new int[st.countTokens()];
			for (int i = 0; i < a.length; i++)a[i] = nextInt();
			return a;
		}
		public boolean ready() throws IOException {return br.ready();}
	}
}