n = int(input())
a = [0] * n
for i in range(n):
	a[i] = int(input())
ans = []
while a != sorted(a):
	ind = 0
	while ind + 1 < n:
		if a[ind] > a[ind + 1]:
			break
		ind += 1
	indS = ind
	while ind + 1 < n and a[ind] > a[ind + 1]:
		ind += 1
	ans.append([indS + 1, ind + 1])
	a = a[:indS] + a[indS:ind + 1][::-1] + a[ind + 1:]
print(len(ans))
for x in ans:
	print(*x)