#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;

#define sz(x) (int)(x).size()
#define ins insert
#define pb push_back
#define ff first
#define ss second
#define bust ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl '\n'

int main()
{
    bust
    ll n, ans = 0;
    cin >> n;
    vl vec(n);
    vector<pair<ll, ll>> res;
    for(int i = 0; i < n; i++){
        cin >> vec[i];
    }
    for(int i = 1; i < n; ++i){
        for(int j = n-1; j >= i; --j){
            if(vec[j] < vec[j-1]){
                swap(vec[j], vec[j-1]);
                res.pb({j, j+1});
                ans += 2;
            }
        }
    }

    cout << ans << '\n';
    for(int i = 0; i < res.size(); i++){
        cout << res[i].ff << " " << res[i].ss << '\n';
    }
    return 0;
}

