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

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

sorted_arr = sorted(arr)

def sort():
    def rev(a, b):
        arr[a:b] = arr[a:b][::-1]

    for i in range(0, n):
        if sorted_arr == arr:
            return
        a = arr.index(i + 1)
        #print(arr, i, a)
        out_arr.append([i + 1, a + 1])
        if a != i:
            rev(i, a + 1)

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