#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx,avx2,tune=native")
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#define int long long
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sqr(x) ((x)*(x))
#define PI 3.14159265358979323846
using namespace std;
using pii = pair <int, int>;
constexpr int maxn = 32000;
constexpr int mod = 998244353;
constexpr long long inf = 1e18 + 10;
constexpr long double eps = 1e-15;
mt19937_64 rng (chrono::steady_clock::now ().time_since_epoch ().count ());

vector <int> a;
vector <pii> w;
vector <pii> res;

vector <int> tree[maxn << 2];

signed main () {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	int n;
    cin >> n;
    a.resize (n);
    for (int i = 0; i < 111; ++i) {
        int l = rng () % n;
        int r = rng () % n;
        cout << l + 1 << ' ' << r + 1 << '\n';
        reverse (a.begin () + l, a.begin () + r + 1);
    }
    for (int i = 0; i < n; ++i) cin >> a[i], w.pb (mp (a[i], rng () % mod));
    sort (all (w));
    for (int i = 0; i < n; ++i) {
        int pos = -1, M = 52552254;
        M = w[i].X;
        for (int j = i; j < n; ++j) if (a[j] == M) {
            pos = j;
            break;
        }
        if (i != pos) res.pb (mp (i + 1, pos + 1));
        reverse (a.begin () + i, a.begin () + pos + 1);
    }
    cout << (int) res.size () << '\n';
    for (pii i: res) cout << i.X << ' ' << i.Y << '\n';
}
