n = int(input())
s = []
for i in range(n):
    s.append(int(input()))
count = 0
l = []
while not sorted(s) == s:
    for i in range(n-1):
        if s[i] > s[i+1]:
            l.append([i+1, i+2])
            count += 1
            s[i], s[i+1] = s[i+1], s[i]
print(count)
for i in l:
    print(*i)