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
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:225450978")
#pragma GCC optimize("Ofast")
using namespace std;
const long long Mod = 1000000007LL, INF = 1e9, LINF = 1e18;
const long double Pi = 3.141592653589793116, EPS = 1e-9,
                  Gold = ((1 + sqrt(5)) / 2);
long long keymod[] = {1000000007LL, 1000000009LL, 1000000021LL, 1000000033LL};
long long keyCount = sizeof(keymod) / sizeof(long long);
template <class T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
  return __builtin_popcountll(s);
}
auto TimeStart = chrono::steady_clock::now();
auto TimeEnd = chrono::steady_clock::now();
void ControlIO(int argc, char* argv[]);
void TimerStart();
void TimerStop();
void Exit();
string cppstr_infile = "FILE.IN";
string cppstr_outfile = "FILE.OUT";
long long n;
vector<long long> a, A;
vector<pair<long long, long long> > List;
map<long long, long long> Map;
vector<bool> isPrime;
void SieveProcess() {
  isPrime.resize(n + 1, true);
  isPrime[0] = false;
  isPrime[1] = false;
  for (long long i = 2; i <= n; i++) {
    if (!isPrime[i]) continue;
    for (long long j = 2; j <= n / i; j++) {
      isPrime[i * j] = false;
    }
  }
}
void ProcessSwap(long long id1, long long id2) {
  List.push_back(make_pair(id1, id2));
  id1--;
  id2--;
  swap(A[id1], A[id2]);
  Map[A[id1]] = id1 + 1;
  Map[A[id2]] = id2 + 1;
}
void Input() {
  cin >> n;
  a.resize(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    A.push_back(a[i]);
    Map[a[i]] = i + 1;
  }
}
void Solve() {
  sort(a.begin(), a.end());
  SieveProcess();
  for (long long i = 0; i < n; i++) {
    long long eid = i + 1, id = Map[a[i]];
    if (id == eid) continue;
    if ((id - eid + 1) % 2 == 0) {
      ProcessSwap(id - 1, id);
      id--;
    }
    if (id == eid) continue;
    while (!isPrime[id - eid + 1]) {
      ProcessSwap(id - 2, id);
      id -= 2;
    }
    ProcessSwap(eid, id);
  }
  cout << List.size() << '\n';
  for (auto x : List) cout << x.first << " " << x.second << '\n';
}
int main(int argc, char* argv[]) {
  ControlIO(argc, argv);
  Input();
  TimerStart();
  Solve();
  TimerStop();
  return 0;
}
void ControlIO(int argc, char* argv[]) {
  char* infile = new char[cppstr_infile.size() + 1];
  char* outfile = new char[cppstr_outfile.size() + 1];
  strcpy(infile, cppstr_infile.c_str());
  strcpy(outfile, cppstr_outfile.c_str());
}
void TimerStart() {}
void TimerStop() {}
void Exit() {
  TimerStop();
  exit(0);
}
