#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("inE.txt", "r", stdin);

    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &i : a)
        cin >> i;
    vector<int> c = a;

    vector<int> b = a;
    sort(b.begin(), b.end());
    vector<pair<int, int>> res;

    int randomn = 0;

    for (int i = 0; i < n; i++) {
        int f;
        if (randomn == 0) {
            for (f = n-1; f >= i; f--)
                if (a[f] == b[i])
                    break;
        }
        else {
            for (f = i; f < n; f++)
                if (a[f] == b[i])
                    break;
        }
        randomn++;
        randomn %= 2;

        if (f > i) {
            res.push_back({i+1, f+1});
            for (int j = i; j <= f; j++) {
                swap(a[j], a[f - j + i]);
                if (j+1 >= f - (j+1) + i)
                    break;
            }
        }
    }

    if (res.size() < 1) {
        cout << res.size() << "\n";
        for (auto i : res) {
            cout << i.first << ' ' << i.second << "\n";
        }
    }
    else {
        vector<pair<int, int>> r;
        bool flag = true;
        while (flag) {
            flag = false;
            for (int i = 0; i < n-1; i++)
                if (c[i] > c[i-1]) {
                    flag = true;
                    r.push_back({i, i+1});
                    swap(c[i-1], c[i]);
                }
        }

        cout << r.size() << "\n";
        for (auto i : r) {
            cout << i.first << ' ' << i.second << "\n";
        }
    }

    return 0;
}