#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

#define fast ios_base::sync_with_stdio();cin.tie();cout.tie();
#define ops cout<<"ops"<<endl;
#define line cout<<"-------------------------------------"<<endl;
#define en cout<<endl;
#define fi first
#define se second

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pllll;
typedef string str;
typedef char cr;

const ll DIM=32e3+7;
const ll DIMM=1e5+7;
const ll DDIM=1e7+7;
const ll INF=1e16+7;
const ll X=1e9;
const ll BS=37;
const ll MODULO=1e9+7;

ll n,m,k;

ll a[DIM],pos[DIM];

vector<pllll> res;

void rev(ll l,ll r){

    res.push_back({l,r});

    ll mid=(l+r)/2;
    ll p1;

    for(int i=l;i<=mid;i++){
     p1=r+l-i;
     swap(a[i],a[p1]);
     pos[a[i]]=i;
     pos[a[p1]]=p1;
    }

    return;
}

void solve()
{

    cin>>n;

    for(int i=1;i<=n;i++){
     cin>>a[i];
     pos[a[i]]=i;
    }

    for(int i=1;i<n;i++){
     if(pos[i]==i)continue;
     rev(i,pos[i]);

     /*line;
     for(int i=1;i<=n;i++)cout<<a[i]<<' ';
     cout<<endl;
     cout<<endl;
     for(int i=1;i<=n;i++)cout<<pos[i]<<' ';
     cout<<endl;
     line;*/
    }

    cout<<res.size()<<endl;

    for(auto w:res)cout<<w.fi<<' '<<w.se<<endl;

    return;
}

int main()
{

    fast;

    int nt;

    nt=1;

    //cin>>nt;

    while(nt--)
        solve();

    return 0;
}
