#include<bits/stdc++.h>
#define int long long
#define endl "\n";

using namespace std;

struct par {
	int l, r;
};

void rev(vector<int> &numb, int l, int r) {
	for(int i = l; i <= (l+r)/2; i++) {
		int c = numb[r-i+l];
		numb[r - i + l] = numb[i];
		numb[i] = c;
	}
}

signed main() {
	
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	
	int n; cin >> n;
	vector<int> numb(n);
	for(int i = 0; i < n; i++) {
		cin >> numb[i];
	}
	
	int l = 0;
	vector<par> t;
	
	for(int f = 1; f <= n; f++) {
		
		if(numb[f-1] == f) continue;
		for(int i = n-1; i >= 0; i--) {
			if(numb[i] == f) {
				t.push_back({min(i+1, f), max(i+1, f)});
				rev(numb, min(i, f-1), max(i, f-1));
				break;
			}
		}	
	}

	cout << t.size() << endl;
	for(int i = 0; i < t.size(); i++) {
		cout << t[i].l << " " << t[i].r << endl;
	}
	
	return 0;
}