def reverse(seq, start, stop):
    size = stop + start
    for i in range(start, (size + 1) // 2):
        j = size - i
        seq[i], seq[j] = seq[j], seq[i]
n = int(input())
lis = []
mi = 10000000
index = 0
lis1 = []
lis2 = []
count = 0
for i in range (n):
    a = int(input())
    lis.append(a)
b = lis
for j in range(n):
    for i in range(j, n):
        if mi >= lis[i]:
            mi = lis[i]
            index = i
    
    reverse(lis, j, index)
    lis1.append(j)
    lis2.append(index)   
    count = j
    mi = 10000000
print(count-1)
for i in range(count-1):
    print(lis1[i]+1, " ", lis2[i]+1)

