class Node:

    solution = []
    ind = 1
    

    def __init__(self, value):
        self.less = None
        self.great = None
        
        self.value = value
        
        self.index = Node.ind
        Node.ind += 1

N = int(input())

G_temp = tuple(map(int, input().split()))

G = Node(G_temp[0])

for i in G_temp[1:]:
    node = Node(i)
    temp = G

    while True:
        if node.value < temp.value:
            if temp.less:
                temp = temp.less
                continue
            else:
                temp.less = node
                break
        else:
            if temp.great:
                temp = temp.great
                continue
            else:
                temp.great = node
                break

temp = G
sol = []

while True:
    if temp.less:
        if temp.less and temp.less.index != temp.index + 1:
            print("Nema spasa")
            exit()

        temp2 = temp.less
        while True:
            last_ind = temp2.index
            if temp2.great or (temp2.less and temp2.less.index != temp2.index + 1):
                print("Nema spasa")
                exit()
                
            try:
                temp2 = temp2.less
            except AttributeError:
                break
            
            if temp2 is None:
                break
            
        sol.append((temp.index, last_ind))

    try:
        temp = temp.great
    except AttributeError:
        break

    if temp is None:
        break

print("Svet je spasen")

print(len(sol))

for x in sol:
    print(x[0], x[1])