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

void sol(int* arr, int b, int e, std::vector<std::pair<int, int> >& res);

int main()
{
    int n;
    scanf("%d", &n);
    int arr[n];
    for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
    std::vector<std::pair<int, int> > res;
    sol(arr, 0, n - 1, res);
    printf("%d\n", (int)res.size());
    for (int i = 0; i < (int)res.size(); i++) printf("%d %d\n", res[i].first + 1, res[i].second + 1);
    return 0;
}


void sol(int* arr, int b, int e, std::vector<std::pair<int, int> >& res)
{
    int nmin = b;
    for (int i = b + 1; i <= e; i++)
        if (arr[i] < arr[nmin]) nmin = i;
    if (b < nmin)
    {
        res.push_back({b, nmin});
        std::reverse(arr + b, arr + nmin + 1);
    }
    if (b + 1 < e) sol(arr, b + 1, e, res);
}
