
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector <ll> v;
ll n;
ll Find(ll k)
{
    ll o = 0;
    for (ll i = 0; i < n ;i++)
    {
        if (v[i] == k) {o = i; break;}
    }
    return o;
}
void Change(ll l, ll r)
{
    for (ll i = 0; i < ((r - l + 2) / 2); i++)
    {
        ll c = v[i + l];
        v[i + l] = v[r - i];
        v[r - i] = c;
    }
}
int main()
{
    cin >> n;
    for (ll i = 0; i < n ;i++)
    {
        ll a;
        cin >> a;
        v.push_back(a);
    }
    vector <pair<ll, ll>> o;
    for (ll i = 1; i < n; i++)
    {
        ll k = Find(i);
        if (k != i - 1) {o.push_back({i, k + 1}); Change(i - 1, k);}
    }
    cout << o.size() << "\n";
    for (ll i = 0; i < o.size(); i++)
    {
        cout << o[i].first << " " << o[i].second << "\n";
    }
}
