#include <bits/stdc++.h>

#define INF 1000000005
#define INFL 1000000000000000005ll
#define EPS 1e-6
#define pb push_back
#define pause system("pause")
#define exit exit(0)
#define endl '\n'

using namespace std;
using ull = unsigned long long;
using ll = long long;

typedef pair<ll, ll> pii;
const int N = 2000005, MOD = 998244353;

int n, a[N], b[N];

inline int get() {
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = i + 1; j <= n; ++j) {
			ans += (a[i] > a[j]) - (b[i] > b[j]);
		}
	}

	return ans;
}

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

	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}

	vector<pii> ans;
	while (!is_sorted(a + 1, a + 1 + n)) {
		int nl = -1, nr = -1;
		double ct = INF;
		for (int l = 1; l < n; ++l) {
			for (int r = l + 1; r <= n; ++r) {
				for (int i = 1; i <= n; ++i) {
					b[i] = a[i];
				}

				reverse(b + l, b + r + 1);
				int prof = get();
				if (prof <= 0)
					continue;

				double nc = prof / (double)(r - l + 1);
				if (nc < ct) {
					ct = nc;
					nl = l, nr = r;
				}
			}
		}

		ans.pb({ nl, nr });
		reverse(a + nl, a + nr + 1);
	}

	cout << ans.size() << endl;
	for (auto x : ans) {
		cout << x.first << ' ' << x.second << endl;
	}
	//pause;
	return 0;
}
