Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
flug = False
kaizen=0

for i in range(1,N):
    if A[i-1]>A[i]:
        kaizen=i
        flug=True
        break
    
if flug==False:
    print(0)
    exit()

keisu=0
keisuichi=0
for i in range(N):
    if abs(A[i])>keisu:
        keisu=A[i]
        keisuichi=i
if keisu>0:
    Ansx=[]
    Ansy=[]    
    while flug==True:
        Ansx.append(keisuichi)
        Ansy.append(kaizen)
        Ansx.append(keisuichi)
        Ansy.append(kaizen)
        A[kaizen]=A[kaizen]+A[keisuichi]*2
        keisuichi=kaizen
        flug=False
        for i in range(1,N):
            if A[i-1]>A[i]:
                kaizen=i
                flug=True
                break
        
    print(len(Ansx))
    for i in range(len(Ansx)):
        print(Ansx[i]+1,Ansy[i]+1)
    
else:
    Ansx=[]
    Ansy=[]
    for i in range(N):
        Ansx.append(keisuichi)
        Ansy.append(N-i)
        Ansx.append(keisuichi)
        Ansy.append(N-i)
        A[N-i-1]=A[N-i-1]+A[keisuichi]*2
        keisuichi=N-i-1
        
        
    print(len(Ansx))
    for i in range(len(Ansx)):
        print(Ansx[i]+1,Ansy[i])
    

Fixed submission:
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
flug = False
kaizen=0

for i in range(1,N):
    if A[i-1]>A[i]:
        kaizen=i
        flug=True
        break
    
if flug==False:
    print(0)
    exit()

keisu=0
keisuichi=0
for i in range(N):
    if abs(A[i])>abs(keisu):
        keisu=A[i]
        keisuichi=i
if keisu>0:
    Ansx=[]
    Ansy=[]
    for i in range(N):
        Ansx.append(keisuichi)
        Ansy.append(i)
        Ansx.append(keisuichi)
        Ansy.append(i)
        A[i]=A[i]+A[keisuichi]*2
        keisuichi=i
        
        
    print(len(Ansx))
    for i in range(len(Ansx)):
        print(Ansx[i]+1,Ansy[i]+1)
    
else:
    Ansx=[]
    Ansy=[]
    for i in range(N):
        Ansx.append(keisuichi)
        Ansy.append(N-i)
        Ansx.append(keisuichi)
        Ansy.append(N-i)
        A[N-i-1]=A[N-i-1]+A[keisuichi]*2
        keisuichi=N-i-1
        
        
    print(len(Ansx))
    for i in range(len(Ansx)):
        print(Ansx[i]+1,Ansy[i])

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
flug = False
kaizen=0

for i in range(1,N):
    if A[i-1]>A[i]:
        kaizen=i
        flug=True
        break
    
if flug==False:
    print(0)
    exit()

keisu=0
keisuichi=0
for i in range(N):
    if abs(A[i])>keisu:
        keisu=A[i]
        keisuichi=i
if keisu>0:
    Ansx=[]
    Ansy=[]    
    while flug==True:
        Ansx.append(keisuichi)
        Ansy.append(kaizen)
        Ansx.append(keisuichi)
        Ansy.append(kaizen)
        A[kaizen]=A[kaizen]+A[keisuichi]*2
        keisuichi=kaizen
        flug=False
        for i in range(1,N):
            if A[i-1]>A[i]:
                kaizen=i
                flug=True
                break
        
    print(len(Ansx))
    for i in range(len(Ansx)):
        print(Ansx[i]+1,Ansy[i]+1)
    
else:
    Ansx=[]
    Ansy=[]    
    while flug==True:
        Ansx.append(keisuichi)
        Ansy.append(kaizen)
        Ansx.append(keisuichi)
        Ansy.append(kaizen)
        A[kaizen]=A[kaizen]+A[keisuichi]*2
        keisuichi=kaizen
        flug=False
        for i in range(1,N):
            if A[i-1]>A[i]:
                kaizen=i
                flug=True
                break
        
    print(len(Ansx))
    for i in range(len(Ansx)):
        print(Ansx[i]+1,Ansy[i]+1)
    

Fixed submission:
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
flug = False
kaizen=0

for i in range(1,N):
    if A[i-1]>A[i]:
        kaizen=i
        flug=True
        break
    
if flug==False:
    print(0)
    exit()

keisu=0
keisuichi=0
for i in range(N):
    if abs(A[i])>abs(keisu):
        keisu=A[i]
        keisuichi=i
if keisu>0:
    Ansx=[]
    Ansy=[]
    for i in range(N):
        Ansx.append(keisuichi)
        Ansy.append(i)
        Ansx.append(keisuichi)
        Ansy.append(i)
        A[i]=A[i]+A[keisuichi]*2
        keisuichi=i
        
        
    print(len(Ansx))
    for i in range(len(Ansx)):
        print(Ansx[i]+1,Ansy[i]+1)
    
else:
    Ansx=[]
    Ansy=[]
    for i in range(N):
        Ansx.append(keisuichi)
        Ansy.append(N-i)
        Ansx.append(keisuichi)
        Ansy.append(N-i)
        A[N-i-1]=A[N-i-1]+A[keisuichi]*2
        keisuichi=N-i-1
        
        
    print(len(Ansx))
    for i in range(len(Ansx)):
        print(Ansx[i]+1,Ansy[i])