n = input()
a=[]
ress=[]
for i in range(int(n)):
    a.append(input())
res=0
for j in range(int(n)):
    prev=a[0]
    up=True
    if(a[0]>a[1]):
        up=False
    start,end = 0,0
    for i in range(int(n)):
        if(prev>=a[i] and up==False):
            end=i
        elif(prev<= a[i] and up==True):
            end=i
            start=i
        elif(prev>=a[i] and up==True):
            up=False
            end=i
            start=i-1
        elif(prev<=a[i] and up==False):
            end=i
            a[start:end]=a[start:end][::-1]
            res+=1
            ress.append([start,end])
            up=True
            start=i
        prev=a[i]
    if(up==False):
        end=int(n)
        a[start:end]=a[start:end][::-1]
        res+=1
        ress.append([start,end])
print(res)
for i in range(res):
    print(ress[i][0],ress[i][1])
