#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    vector <ll> v,q;
    for (ll i=0;i<n;i++)
    {
        ll a;
        cin>>a;
        v.push_back(a);
        q.push_back(a);
    }
    ll a[50000],b[50000];
    ll c=0;
    sort(q.begin(),q.end());
    for (ll i=0;i<n;i++)
    {
        if (v[i]!=q[i])
        {
            ll r;
            for (ll j=i+1;j<n;j++)
                if (v[j]==q[i]) {r=j;j=n;}
            for (ll j=i;j<=i+(r-i)/2;j++)
            {
                swap(v[j],v[r+i-j]);
            }
            c++;
            a[c]=i;
            b[c]=r;
        }
    }
    cout<<c<<endl;
    for (ll i=1;i<=c;i++)
    {
        cout<<a[i]+1<<" "<<b[i]+1<<endl;
    }
}
