import sys;input=sys.stdin.readline
n=int(input())
l=[int(input()) for i in range(n)]
h=sorted(l)
ans=[]
for i in range(n):
    if l[i]!=h[i]:
        for j in range(i+1,n):
            if l[j]==h[i]:
                ans.append([i+1,j+1])
                l[i:j+1]=l[i:j+1][::-1]
                break
print(len(ans))
for i in range(len(ans)):
    print(ans[i][0],ans[i][1])
