n = int(input())
a = [0] * n
for i in range(n):
	a[i] = int(input())

ans = []
for i in range(n - 1):
	for j in range(n - i - 1):
		if a[j] > a[j + 1]:
			#print(a[j], a[j + 1])
			#print(ans)
			ans.append([j + 1, j + 2])
			a[j], a[j + 1] = a[j + 1], a[j]
			#print(a)

print(len(ans))
for x in ans:
	print(*x)