n = int(input()) *a, = map(int,input().split()) res = [] for i in range(n): for j in range(n-i-1): if a[j] > a[j+1]: res.append((j+1,j+2)) a[j+1],a[j] = a[j],a[j+1] print(len(res)) for x,y in res: print(x,y) import sys sys.stdout.flush() input()