def sort (mas):
    l=len(mas)
    while l>1:
        max_index=mas.index(max(mas[0:l]))
        mas = mas[max_index::-1]+mas[max_index+1:len(mas)]
        mas = mas[l-1::-1]+mas[l:len(mas)]
        l-=1
        print(max_index, l)
n = int(input())
a=[]
for i in range(n):
    a.append(int(input()))
print(n-1)
sort(a)

