N = int(input()) A = list(map(int,input().split())) ans = [] while A: x = A.index(max(A)) while x + 1 < len(A): if A[x] != A[x+1]: A[x],A[x+1] = A[x+1],A[x] ans.append((x,x+1)) x += 1 A.pop() print(len(ans)) for a in ans: print(*a)