Xenia the horse breeder has n (n > 1) horses that stand in a row. Each horse has its own unique number. Initially, the i-th left horse has number i. That is, the sequence of numbers of horses in a row looks as follows (from left to right): 1, 2, 3, ..., n.

Xenia trains horses before the performance. During the practice sessions, she consistently gives them commands. Each command is a pair of numbers l, r (1 ≤ l < r ≤ n). The command l, r means that the horses that are on the l-th, (l + 1)-th, (l + 2)-th, ..., r-th places from the left must be rearranged. The horses that initially stand on the l-th and r-th places will swap. The horses on the (l + 1)-th and (r - 1)-th places will swap. The horses on the (l + 2)-th and (r - 2)-th places will swap and so on. In other words, the horses that were on the segment [l, r] change their order to the reverse one.

For example, if Xenia commanded l = 2, r = 5, and the sequence of numbers of horses before the command looked as (2, 1, 3, 4, 5, 6), then after the command the sequence will be (2, 5, 4, 3, 1, 6).

We know that during the practice Xenia gave at most three commands of the described form. You have got the final sequence of numbers of horses by the end of the practice. Find what commands Xenia gave during the practice. Note that you do not need to minimize the number of commands in the solution, find any valid sequence of at most three commands.

Input

The first line contains an integer n (2 ≤ n ≤ 1000) — the number of horses in the row. The second line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ n), where ai is the number of the i-th left horse in the row after the practice.

Output

The first line should contain integer k (0 ≤ k ≤ 3) — the number of commads Xenia gave during the practice. In each of the next k lines print two integers. In the i-th line print numbers li, ri (1 ≤ li < ri ≤ n) — Xenia's i-th command during the practice.

It is guaranteed that a solution exists. If there are several solutions, you are allowed to print any of them.

Examples

Input

5
1 4 3 2 5


Output

1
2 4


Input

6
2 1 4 3 6 5


Output

3
1 2
3 4
5 6
#include <bits/stdc++.h>
const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;
long long readInt() {
  bool minus1 = false;
  long long result = 0;
  char ch;
  ch = getchar();
  while (true) {
    if (ch == '-') break;
    if (ch >= '0' && ch <= '9') break;
    ch = getchar();
  }
  if (ch == '-')
    minus1 = true;
  else
    result = ch - '0';
  while (true) {
    ch = getchar();
    if (ch < '0' || ch > '9') break;
    result = result * 10 + (ch - '0');
  }
  if (minus1)
    return -result;
  else
    return result;
}
int a[MAXN];
int n;
vector<pair<int, int> > ans;
void rec(int lvl) {
  bool ok = 1;
  for (int i = 1; i <= n; i++) {
    if (a[i] != i) ok = 0;
  }
  if (ok) {
    cout << ans.size() << '\n';
    reverse(ans.begin(), ans.end());
    for (pair<int, int> i : ans) {
      cout << i.first << ' ' << i.second << '\n';
    }
    exit(0);
  }
  if (lvl == 3) {
    return;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (abs(a[i - 1] - a[j]) == 1 || abs(a[j + 1] - a[i]) == 1) {
        ans.push_back({i, j});
        reverse(a + i, a + j + 1);
        rec(lvl + 1);
        reverse(a + i, a + j + 1);
        ans.pop_back();
      }
    }
  }
}
int main() {
  n = readInt();
  for (int i = 1; i <= n; i++) {
    a[i] = readInt();
  }
  a[0] = 0;
  a[n + 1] = n + 1;
  rec(0);
  return 0;
}
