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