#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
#include <queue>
#include <string>
#include <iomanip>
#include <set>
#include <cmath>

#define LF '\n'

using namespace std;
typedef long long int lli;

vector<int> v;
vector<int> k;
vector<pair<int, int>> ans;

void solve()
{
    int n;
    lli cnt = 0;
    cin >> n;
    v.resize(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    k = v;
    sort(k.begin(), k.end());
    for (int i = 0; i < n; i++) {
        int x;
        for (int j = i; j < n; j++) {
            if (v[j] == k[i]) {
                x = j;
                break;
            }
        }
        if (x != i) {
            cnt += (x - i + 1);
            ans.push_back({ i+1,x+1 });
            reverse(v.begin() + i, v.begin() + x+1);
        }
    }
    cout << cnt << LF;
    for (auto to : ans) {
        cout << to.first << " " << to.second << LF;
    }
}

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

#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    solve();
}

