#include <bits/stdc++.h>

using namespace std;

long long n, a[32007], l, r, sz;

vector<pair<long long, long long> > ans;

void my_sort(long long l, long long r){
    if(l==r) return;
    long long m=(l+r)/2;
    my_sort(l, m);
    my_sort(m+1, r);
    vector<long long> vec;
    long long it1=l;
    long long it2=m+1;
    long long cnt=0;
    while(it1<=m || it2<=r){
        if(it1==m+1){
            while(it2<=r){
                vec.push_back(a[it2]);
                it2++;
            }
            break;
        }
        if(it2==r+1){
            while(it1<=m){
                vec.push_back(a[it1]);
                it1++;
            }
            break;
        }
        if(a[it1]<=a[it2]){
            vec.push_back(a[it1]);
            it1++;
        }
        else{
            ans.push_back({it1+cnt, it2});
            ans.push_back({it1+cnt+1, it2});
            cnt++;
            vec.push_back(a[it2]);
            it2++;
        }
    }
    for(int i=l; i<=r; i++) a[i]=vec[i-l];
    vec.clear();
    return;
}

int main(){
    scanf("%lld", &n);
    for(int i=1; i<=n; i++) scanf("%lld", &a[i]);
    my_sort(1, n);
    sz=ans.size();
    printf("%lld\n", sz);
    for(int i=0; i<sz; i++){
        l=ans[i].first;
        r=ans[i].second;
        printf("%lld %lld\n", l, r);
    }
    return 0;
}
