def recursort(l, r):
    global arr, ans
    
    if l==r:
        return None
    
    mid=(l+r)//2
    recursort(l, mid)
    recursort(mid+1, r)
    if arr[mid]>arr[mid+1]:
        arr[mid], arr[mid+1]=arr[mid+1], arr[mid]
        el=[mid+1, mid+2]
        ans.append(el)
        

n=int(input())
arr=[]
for i in range(n):
    a=int(input())
    arr.append(a)
ans=[]
for i in range(n):
    recursort(0, n-1)

print(len(ans))
for i in range(len(ans)):
    print(ans[i][0], ans[i][1])