n = int(input())
a = [int(input()) for i in range(n)]
b = sorted(a)
k = 0
ind = -1
while k < n:
    while a[k] == b[k]:
        k += 1
        print(k)
    ind = n - 1
    while a[ind] != b[k]:
        ind -= 1
    if ind == k:
        break
    s1 = a[:k]
    s2 = a[ind - 1:k - 1:-1]
    s3 = a[ind:]
    a = s1 + s2 + s3
    print(k + 1, ind + 1)