#include <bits/stdc++.h>

using namespace std;

int cnt(const vector<int> &a) {
//    for (auto i : a)cout << i << " ";
//    cout << endl;
    int cur = 0;
    for (int i = 0; i < a.size(); i++) {
        for (int j = 0; j < i; j++) {
            if (a[j] > a[i])cur++;
        }
    }
//    cout << " !!  " << cur << endl;
    return cur;
}

int n;
vector<int> a;
vector<pair<int, int> > ans;

int main()
{
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    while (true) {
        int L = -1, R = -1;
        int cur = 10101010;
        vector<int> now = a;
        for (int l = 0; l < n; l++) {
            a = now;
            for (int i = 1;; i++) {
                if (l - i < 0 || l + i >= a.size())break;
                swap(a[l - i], a[l + i]);
                int GtCnt = cnt(a);
                if (cur > GtCnt) {
                    cur = GtCnt;
                    L = l - i;
                    R = l + i;
                }
            }
        }
        for (int l = 0; l < n; l++) {
            a = now;
            for (int i = 0;; i++) {
                if (l - i < 0 || l + i + 1 >= a.size())break;
                swap(a[l - i], a[l + i + 1]);
                int GtCnt = cnt(a);
                if (cur > GtCnt) {
                    cur = GtCnt;
                    L = l - i;
                    R = l + i + 1;
                }
            }
        }
        a = now;

        ans.push_back({L, R});
//        cout << L << " " << R << " <<<                 " << cur << endl;
        while (L < R) {
            swap(a[L], a[R]);
            L++;R--;
        }
        bool ok = true;
        for (int i = 0; i + 1 < a.size(); i++)
        if (a[i] > a[i + 1]){ok = false;break;}
        if (ok)break;
//        cout << "-------------------------------------------" << endl;
//        cout << cnt(a) << endl;
//        cout << endl;
    }
    cout << ans.size() << '\n';
    for (auto [i, j] : ans)
        cout << i + 1 << " " << j + 1 << '\n';
}
/**
5
2 4 3 5 1
2 1 5 3 4
2 1 4 3 5
1 2 3 4 5


5
2 4 3 5 1
1 5 3 4 2
1 2 4 3 5
1 2 3 4 5
*/
