#include <bits/stdc++.h>

using namespace std;
typedef int ll;
#define INF 1000000007
#define MAXN 200007

ll isPrime(ll n) {
    if (n < 2) {
        return false;
    }
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

ll binpow(ll n, ll p) {
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        ll b = binpow(n, p / 2);
        return b * b;
    }
    return binpow(n, p - 1) * n;
}

bool isPal(ll n) {
    string s = to_string(n);
    for (ll i = 0; i < s.length() / 2; i++) {
        if (s[i] != s[s.length() - i - 1]) {
            return false;
        }
    }
    return true;
}


void solve() {
    ll n;
    cin >> n;
    ll a[n];
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<pair<ll, ll>> ans;
    for (ll i = 0; i < n - 1; i++) {
        for (ll j = 0; j < n - i - 1; j++) {
            if (a[j] > a[j + 1]) {
                ans.push_back({j + 1, j + 2});
                swap(a[j], a[j + 1]);
            }
        }
    }
    cout << ans.size() << "\n";
    for (ll i = 0; i < ans.size(); i++) {
        cout << ans[i].first << " " << ans[i].second << "\n";
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie();

    ll t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}
