#include "bits/stdc++.h"
using namespace std;

#define DIM 32007

typedef long long ll;
typedef long double ld;


ll n, a[DIM], rs, l, r;
vector<ll> v;
pair<ll, ll> res[DIM];

ll bin(ll l, ll r, ll x){
    ll m = 0;
    while(l<r){
        m = (l+r+1)/2;
        if(v[m]>x) r = m-1;
        else l = m;
    }
    if(v[l]<x && v[l]!=0) l++;
    if(l!=0 && v[l-1] >=x) l--;
    return l;
}


int main(){
    
    cin>>n;
    
    for(int i=1;i<=n;i++){
        cin>>a[i];
        
    }
    rs = 0;
    v.insert(v.begin(), a[1]);
    for(int i = 2; i<=n;i++){
        l = bin(0, i-2, a[i]);
        v.insert(v.begin()+l, a[i]);
        
        r = i;
        l +=1;
        
        
        if(r-l>=1){
            rs++;
            res[rs] = {l, r};
        }
        l+=1;
        
        if(r-l>=1){
            rs++;
            res[rs] = {l, r};
        }
    }
    
    cout<<rs<<endl;
    
    for(int i=1;i<=rs;i++){
        cout<<res[i].first<<" "<<res[i].second<<endl;
    }
    
    
    return 0;
}
