#include <bits/stdc++.h>

#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,tune=native")
using namespace std;

typedef int ll;
typedef long double ld;

#define ff first
#define ss second
#define pb push_back
#define el "\n"
#define se " "

const ll N=1e5+9;
const ll INF=1e18;

ll n,m,a,b,c,d,k,kk,i,j,cnt,cnt1,res,res1,sum,sum1,val,cur;
ll A[N],srt[N];
pair<ll,ll>pp[N];
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>A[i],srt[i]=A[i];
    }
    sort(srt+1,srt+1+n);
    a=1;
    for(i=1;i<n;i++){
        ll ans=srt[i];
        if(ans!=A[i]){
            kk=0;
            for(ll it=i+1;it<=n;it++){
                if(kk==1){
                    break;
                }
                if(ans==A[it]){
                    pp[a].ff=i,pp[a].ss=it,a++;
                    reverse(A+i,A+1+it);
                    kk=1;
                }
            }
        }
    }
    cout<<a-1<<el;
    for(i=1;i<a;i++){
        cout<<pp[i].ff<<se<<pp[i].ss<<el;
    }
}
