import sys
input = sys.stdin.readline
x = []
n = int(input())
for i in range(n):
    x.append(int(input()))
ans1 = 0
ans2 = []
y = x[:]
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
print(ans1)
x = y[:]
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]
            print(j + 1, j + 2)
