import sys
input = sys.stdin.readline
x = []
n = int(input())
for i in range(n):
    x.append(int(input()))
ans1 = 0
ans2 = []
for i in range(n):
    for j in range(n - 1):
        if x[j] > x[j + 1]:
            x[j], x[j + 1] = x[j + 1], x[j]
            ans1 += 1
            ans2.append((j + 1, j + 2))
print(ans1)
for i in ans2:
    print(*i)

