#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define pb push_back
typedef long long ll;

const int nmax=200010;

tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ost;

int mas[nmax]={0};
vector<pair<int,int>> ans;

int main()
{
    //ios_base::sync_with_stdio(0);
    //cin.tie(0);
    int n;
    cin >> n;
    for(int i=1;i<=n;i++) {
        cin >> mas[i];
    }
    for(int i=0;i<n;i++) {
        for(int j=1;j<n-i;j++) {
            if(mas[j]>mas[j+1]) {
                swap(mas[j],mas[j+1]);
                ans.pb({j,j+1});
            }
        }
    }
    cout << ans.size() << "\n";
    for(auto i:ans) {
        cout << i.first << " " << i.second << "\n";
    }
    return 0;
}
