#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pi 3.14159265358979323846
#define sqr(a) (a)*(a)
#define v vector
#define ll long long
#define ld long double
#define f first
#define sec second
#define pb push_back
#define pf push_front
#define umap unordered_map
#define sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define mod 1000000007
#define inf 2*1e18

using namespace std;
using namespace __gnu_pbds;

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>uset;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(time(NULL));
    ll n,i,j,p;
    cin>>n;
    v<ll>a(n),b;
    for (i=0;i<n;i++){
        cin>>a[i];
    }
    b=a;
    sort(b);
    v<pair<ll,ll>>res;
    for (i=0;i<n;i++){
        if (a[i]==b[i]){
            continue;
        }
        j=i;
        while (a[j]!=b[i]){
            j++;
        }
        res.pb({i+1,j+1});
        p=i;
        while (p<j){
            swap(a[p],a[j]);
            p++;
            j--;
        }
    }
    cout<<res.size()<<endl;
    for (auto pa : res){
        cout<<pa.f<<' '<<pa.sec<<endl;
    }
    return 0;
}
