#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <iostream>
#include <vector>
#include <string>

#define pb push_back

using namespace std;
using ll = long long;
using ull = unsigned long long;
using dl = double;

const ll N = 32100;
const ll inf = 100000000000;

ifstream in("input.txt");
ofstream out("output.txt");

const ll LL = 10000000;
ll n;
ll a[N];
ll c;
pair<ll, ll> v[LL + 5];

int main() {

    in >> n;
    for (ll i = 0; i < n; ++i) {
        in >> a[i];
    }

    for (ll i = 0; i < n; ++i) {
        ll o = 0;
        for (ll j = 1; j < n; ++j) {
            if (a[j - 1] > a[j]) {
                ++o;
                swap(a[j - 1], a[j]);
                if (c >= LL) break;
                v[c++] = {j-1, j};
            }
        }
        if (o == 0) break;
    }
    out << c << endl;
    for (ll i = 0; i < c; ++i) {
        out << v[i].first + 1 << " " << v[i].second + 1 << endl;
    }

//    while (true) {
//        ll d = 0;
//        ll cd = 0;
//        for (ll i = 1; i < n; ++i) {
//            if (a[i - 1] > a[i]) {
//                ++cd;
//            } else {
//                if (cd > d) {
//
//                }
//            }
//        }
//
//        break;
//    }

    return 0;
}