input() a=input().split() l=[] for i in range(len(a)): for j in range(i,len(a)-1): if a[j]>a[j+1]:l+=[j,j+1];a[j],a[j+1]=a[j+1],a[j] print(len(l)//2) for i in range(0,len(l),2):print(l[i],l[i+1]) input()