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>
using namespace std;
void __print(long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  long long f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
inline long long GCD(long long x, long long y) {
  long long r = x % y;
  while (r) {
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}
const long long N = 1e6 + 69;
bool is_prime[1000001];
void sieve() {
  long long maxN = 1000000;
  for (long long i = 1; i <= maxN; i++) is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for (long long i = 2; i * i <= maxN; i++) {
    if (is_prime[i]) {
      for (long long j = i * i; j <= maxN; j += i) {
        is_prime[j] = false;
      }
    }
  }
}
long long a[N], p[N];
vector<pair<long long, long long> > ans;
void sp(long long i, long long j) {
  long long x = a[i], y = a[j];
  a[j] = x, p[x] = j;
  a[i] = y, p[y] = i;
  ans.push_back({i, j});
}
signed main() {
  sieve();
  vector<long long> v;
  for (long long i = 1; i < 1e6 - 2; i++) {
    if (is_prime[i]) v.push_back(i);
  }
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    p[a[i]] = i;
  }
  for (long long i = 1; i <= n; i++) {
    long long pos = p[i];
    ;
    while (pos - i > 0) {
      auto it = upper_bound(v.begin(), v.end(), pos - i + 1);
      it--;
      long long j = *it;
      ;
      sp(pos - j + 1, pos);
      pos = pos - j + 1;
    }
  }
  cout << (long long)ans.size() << '\n';
  for (pair<long long, long long> op : ans)
    cout << op.first << " " << op.second << '\n';
  return 0;
}
