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