n = int(input())
c = [int(input()) for i in range(n)]
vid = sorted(c)
q = 0
rez = []
while True:
    for i in range(n):
        if c[i] != vid[i]:
            l = i
    for i in range(n-1, -1, -1):
        if c[i] != vid[i]:
            r = i
    if l < r:
        q += 1
        rez += [[l+1, r+1]]
print(q)
for i in rez:
    print(*i)