#include <bits/stdc++.h>
using namespace std;

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

    int n;
    cin >> n;
    int a[n];
    for (int i=0; i<n; i++) {
        cin >> a[i];
    }
    int c=0;
    vector <pair<int,int>> p;
    int x=0;
    for (int i=0; i<n; i++) {
        int k=x,kmin=a[x];
        for (int j=x; j<n; j++) {
            if (kmin>a[j]) {
                kmin=a[j];
                k=j;
            }
        }
        if (k!=x) {
            for (int j=0; j<=(k-x)/2; j++) {
                int t=a[j+x];
                a[j+x]=a[k-j];
                a[k-j]=t;
                //cout << a[k-j] << " " << a[j+x] << endl;
            }
            p.push_back({x+1,k+1});
            c++;
            x++;
        }

    }
    cout << c << endl;
    for (int i=0; i<p.size(); i++) {
        cout << p[i].first << " " << p[i].second << endl;
    }

}