n=int(input()) a=list(map(int,input().split())) o=[] for i in range(n): for j in range(n-1): if a[j]>a[j+1]: o+=[(j,j+1)] a[j],a[j+1]=a[j+1],a[j] print(len(o)) for x,y in o: print(x,y)