n = int(input())
arr = []
out_arr = []

for i in range(n):
    arr.append(int(input()))

def sort():
    def rev(a, b):
        arr[a:b] = arr[a:b][::-1]
    itr = 1
    while arr:
        a = arr.index(min(arr))
        if itr != a + itr:
            out_arr.append([itr, a + itr])
        rev(0, a + 1)
        arr.pop(0)
        itr += 1

sort()
print(len(out_arr))
for i in range(len(out_arr)):
    print(*out_arr[i])