Snuke has an integer sequence, a, of length N. The i-th element of a (1-indexed) is a_{i}.
He can perform the following operation any number of times:
 - Operation: Choose integers x and y between 1 and N (inclusive), and add a_x to a_y.
He would like to perform this operation between 0 and 2N times (inclusive) so that a satisfies the condition below. Show one such sequence of operations.
It can be proved that such a sequence of operations always exists under the constraints in this problem.
 - Condition: a_1 \leq a_2 \leq ...  \leq a_{N}

-----Constraints-----
 - 2 \leq N \leq 50
 - -10^{6} \leq a_i \leq 10^{6}
 - All input values are integers.

-----Input-----
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_{N}

-----Output-----
Let m be the number of operations in your solution. In the first line, print m.
In the i-th of the subsequent m lines, print the numbers x and y chosen in the i-th operation, with a space in between.
The output will be considered correct if m is between 0 and 2N (inclusive) and a satisfies the condition after the m operations.

-----Sample Input-----
3
-2 5 -1

-----Sample Output-----
2
2 3
3 3

 - After the first operation, a = (-2,5,4).
 - After the second operation, a = (-2,5,8), and the condition is now satisfied.

Difficulty: competition

Starter code:

Solutions:
N = int(input())
A = list(map(int,input().split()))
if min(A) >= 0:
  Flag = True
elif max(A) <= 0:
  Flag = False
else:
  p_max = max(A)
  m_max = min(A)
  if abs(p_max) >= abs(m_max):
    Flag = True
  else:
    Flag = False
if Flag:
  MAX = max(A)
  for i,v in enumerate(A):
    if v == MAX:
      MAX_loc = i
      break
  ans = []; t = 0
  for i in range(N-1):
    if A[i+1] >= A[i]:
      continue
    A[i+1] += 2*MAX
    ans.append([MAX_loc+1,i+1+1])
    ans.append([MAX_loc+1,i+1+1])
    t += 2
    MAX_loc = i+1
    MAX = A[i+1]

else:
  MIN = min(A)
  for i, v in enumerate(A):
    if v == MIN:
      MIN_loc = i
      break
  ans = []; t = 0
  for i in range(N-1):
    if A[N-1-i] >= A[N-2-i]:
      continue
    A[N-2-i] += 2*MIN
    ans.append([MIN_loc+1,N-2-i+1])
    ans.append([MIN_loc+1,N-2-i+1])
    t += 2
    MIN_loc = N-2-i
    MIN = A[N-2-i]
print(t)
for x in ans:
  print((*x))
#print(ans,t,A)    


# coding:UTF-8
import sys

MOD = 10 ** 9 + 7
INF = float('inf')

N = int(input())    # 数字
a = list(map(int, input().split()))     # スペース区切り連続数字
a_res = [0] * N

m_value = 0
m_pos = -1

for i in range(N):
    if abs(a[i]) > abs(m_value):
        m_value = a[i]
        m_pos = i

res = []
if m_pos == -1:
    print(0)
    return

if m_value > 0:
    v = a[0]
    for i in range(N):
        if a[i] >= v:
            v = a[i]
            a_res[i] = a[i]
        else:
            a_tmp = a[i]
            a_tmp += m_value
            res.append([m_pos, i])
            if a_tmp < v:
                a_tmp += m_value
                res.append([m_pos, i])
            a_res[i] = a_tmp
            v = a_tmp
            if a_tmp > m_value:
                m_value = a_tmp
                m_pos = i
else:
    v = a[-1]
    for i in reversed(range(N)):
        if a[i] <= v:
            v = a[i]
            a_res[i] = a[i]
        else:
            a_tmp = a[i]
            a_tmp += m_value
            res.append([m_pos, i])
            if a_tmp > v:
                a_tmp += m_value
                res.append([m_pos, i])
            a_res[i] = a_tmp
            v = a_tmp
            if a_tmp < m_value:
                m_value = a_tmp
                m_pos = i


print("{}".format(len(res)))
for i in range(len(res)):
    print("{} {}".format(res[i][0]+1, res[i][1]+1))

N = int(input())
Z = list(map(int,input().split()))
A = []
for i in range(N):
  A.append([Z[i],i])
MIN = min(A)
MAX = max(A)
#print(A,MAX,MIN)
#print(MIN,MAX)
ans = []
num = 0
if abs(MIN[0]) > abs(MAX[0]):
  Flag = False
  minloc = MIN[1]
  for i in range(N):
    #print(minloc+1,i+1) #1indexにして出力
    ans.append((minloc+1,i+1))
    num += 1
    A[i][0] += MIN[0]
else:
  Flag = True
  maxloc = MAX[1]
  for i in range(N):
    #print(maxloc+1,i+1)
    ans.append((maxloc+1,i+1))
    num +=1
    A[i][0] += MAX[0]

for i in range(N-1):
  if Flag == True:
    ans.append((i+1,i+2))
  else:
    ans.append((N-i,N-1-i))
  num+=1
print(num)
for i in range(len(ans)):
  print((*ans[i]))



def main():
    MAX_ = 10 ** 6

    N = int(input())
    A = list(map(int, input().split()))

    mi = MAX_
    mii = -1

    ma = -MAX_
    mai = -1

    for i, x in enumerate(A):
        if mi > x:
            mi = x
            mii = i + 1
        if ma < x:
            ma = x
            mai = i + 1

    if mi >= 0:
        print((N - 1))
        for i in range(1, N):
            print((i, i + 1))
        return

    if ma <= 0:
        print((N - 1))
        for i in range(N - 1, 0, -1):
            print((i + 1, i))
        return

    print(((N - 1) * 2))
    if ma + mi >= 0:
        for i in range(1, N + 1):
            if i == mai: continue
            print((mai, i))
        for i in range(1, N):
            print((i, i + 1))
        return
    else:
        for i in range(1, N + 1):
            if i == mii: continue
            print((mii, i))
        for i in range(N - 1, 0, -1):
            print((i + 1, i))
        return


def __starting_point():
    main()

__starting_point()

import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    ma = max(a)
    mi = min(a)
    if mi*ma < 0:
        print((2*(n-1)))
        if abs(ma) > abs(mi):
            mk = a.index(ma)
            for i in range(n):
                if i == mk:
                    continue
                print((mk+1,i+1))
                a[i] += ma
        else:
            mk = a.index(mi)
            for i in range(n):
                if i == mk:
                    continue
                print((mk+1,i+1))
                a[i] += mi
    else:
        print((n-1))
    ma = max(a)
    mi = min(a)
    if ma <= 0:
        for i in range(n-1):
            print((n-i,n-i-1))
    else:
        for i in range(n-1):
            print((i+1,i+2))


    return

def __starting_point():
    main()

__starting_point()

import sys
#import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

#最小値と最大値の絶対値がどちらが大きいか
N = ir()
A = lr()
if abs(max(A)) >= abs(min(A)):
    i = A.index(max(A))
    print((2*(N-1)))
    print((i+1, 2))
    print((i+1, 2))
    for i in range(2, N):
        print((i, i+1))
        print((i, i+1))
else:
    i = A.index(min(A))
    print((2*(N-1)))
    print((i+1, N-1))
    print((i+1, N-1))
    for i in range(2, N):
        print((N-i+1, N-i))
        print((N-i+1, N-i))

# 50


N = int(input())
A = list(map(int,input().split()))
maxA = max(A)
minA = min(A)

if minA >=0 or 2*abs(maxA)>abs(minA):
  maxi = A.index(maxA)
  print((2*N-1))
  print((maxi+1,maxi+1))

  for i in range(N):
    if i == maxi:continue
    print((maxi+1,i+1))
  
  for i in range(N-1):
    print((i+1,i+2))

else:
  mini = A.index(minA)
  print((2*N-1))
  print((mini+1,mini+1))
  for i in range(N):
    if i == mini: continue
    print((mini+1, i+1))
  
  for i in range(N-1, 0, -1):
    print((i+1,i))


from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,copy
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
mx = 0
pl = None
ind = -1
res = []
for i,x in enumerate(a):
    if abs(x) > mx:
        mx = abs(x)
        ind = i
        pl = True if x > 0 else False
if mx == 0:
    print(0)
    return
if not pl: mx *= -1
for i in range(n):
    if i == ind: continue
    res.append([ind+1,i+1])
    a[i] += mx
if pl:
    for i in range(n-1):
        res.append([i+1,i+2])
else:
    for i in range(n-1)[::-1]:
        res.append([i+2,i+1])
print(len(res))
for x in res:
    print(*x)

n=int(input())
a=list(map(int,input().split()))

max=-9999999999999999999
min=9999999999999999999
for i in a:
    if max<i:
        max=i
    if min>i:
        min=i
maxindex=a.index(max)+1
minindex=a.index(min)+1

ans=[]

if min>=0:
    for i in range(n-1):
        ans.append([i+1,i+2])

elif max<=0:
    for i in range(n-1):
        ans.append([n-i,n-i-1])

elif max>=abs(min):
    for i in range(1,n+1):
        if i!=maxindex:
            ans.append([maxindex,i])
    for i in range(n-1):
        ans.append([i+1,i+2])
elif max<abs(min):
    for i in range(1,n+1):
        if i!=minindex:
            ans.append([minindex,i])
    for i in range(n-1):
        ans.append([n-i,n-i-1])

print(len(ans))
for i in ans:
    print(*i)

n=int(input())
A=[int(i) for i in input().split()]

mode=0
cnt=0

ans=[]

def do(a,b):
    nonlocal cnt
    cnt+=1
    A[b]+=A[a]
    ans.append((a+1,b+1))

def doMAX(b):
    if b==-1:
        b+=n
    do(A.index(max(A)),b)

def doMIN(b):
    if b==-1:
        b+=n
    do(A.index(min(A)),b)

if abs(max(A))>=abs(min(A)):
    doMAX(-1)
    mode=0
elif abs(max(A))<abs(min(A)):
    doMIN(0)
    mode=1
else:
    doMAX(-1)
    mode=0

if mode==0:
    old=-10**30
    for i in range(n-1):
        if A[i]>=old:
            old=A[i]
            continue
        while A[i]+A[-1]<old:
            doMAX(-1)
        doMAX(i)
        old=A[i]
    while A[-1]<old:
        doMAX(-1)
    #print(A,cnt)
elif mode==1:
    old=10**30
    for i in range(n-1,0,-1):
        if A[i]<=old:
            old=A[i]
            continue
        while A[i]+A[0]>old:
            doMIN(0)
        doMIN(i)
        old=A[i]
    while A[0]>old:
        doMIN(0)
    #print(A,cnt)
else:
    pass
#print(A,cnt)
print(cnt)
for ele in ans:
    print((ele[0],ele[1]))


n = int(input())
a = list(map(int, input().split()))

maxi = max(list(range(n)), key=lambda x: a[x])
maxa = a[maxi]
mini = min(list(range(n)), key=lambda x: a[x])
mina = a[mini]
out = []
if maxa > -mina:
    for i in range(1, n):
        while a[i] < a[i-1]:
            out.append((maxi+1, i+1))
            a[i] = a[i] + maxa
        if a[i] > maxa:
            maxa = a[i]
            maxi = i
else:
    for i in range(n-2, -1, -1):
        while a[i+1] < a[i]:
            out.append((mini+1, i+1))
            a[i] = a[i] + mina
        if a[i] < mina:
            mina = a[i]
            mini = i

print((len(out)))
for o in out:
    print((o[0], o[1]))


"""
xとyが同じでもよいことに注意。
それぞれに自分以外の数を全部足したら、全部同じ数になるな。それも一つの正解か？
まずA1に、O(N-1)回で自分以外の数を全部足す。
次に、A2に+A1の2回で同様に同じ数にする。ってやると全体でO(2N-2+N-1)=O(3N-3)かかるな。

同じ数にするのはハードル高くても、昇順なら
一番左から昇順に直していく。

全部0以上にするか、全部0以下にするかしたい。
全部正にしたら左から累積和。
全部負にしたら右から累積和を取れば正解にになる。

そのためにはセットアップが必要。
初期状態で最大値と最小値を探す。
最大値も最小値も0以上あるいは、最大値も最小値も0以下ならセットアップ不要。
最大値が0以上、最小値が負の値の時はセットアップが必要。
abs(最大値) >= abs(最小値)なら全部に最大値を加える。
abs(最大値) < abs(最小値)なら全部に最小値を加える。

こうすることで、数列を正の値か負の値どちらかにそろえることができる。
"""
N = int(input())
A = list(map(int,input().split()))
MAX = max(A)
MIN = min(A)
MAXidx = A.index(MAX)+1
MINidx = A.index(MIN)+1

def positiveOpe():
    for i in range(1,N):
        print((i,i+1))

def negativeOpe():
    for i in range(N,1,-1):
        print((i,i-1))

if MIN >= 0:
    print((N-1))
    positiveOpe()
elif MAX <= 0:
    print((N-1))
    negativeOpe()
elif abs(MAX) >= abs(MIN):
    print((N-1+N))
    for i in range(1,N+1):
        print((MAXidx,i))
    positiveOpe()
else:
    print((N-1+N))
    for i in range(1,N+1):
        print((MINidx,i))
    negativeOpe()


import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: list(map(int, readline().split()))
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: list(map(int, read().split()))


def main():

    N = in_n()
    A = in_nl()

    ans = []
    if abs(min(A)) < abs(max(A)):
        ma = max(A)
        ind = A.index(ma)
        for i in range(N):
            if i != ind:
                ans.append((ind + 1, i + 1))
                A[i] += A[ind]
    else:
        ma = min(A)
        ind = A.index(ma)
        for i in range(N):
            if i != ind:
                ans.append((ind + 1, i + 1))
                A[i] += A[ind]

    if min(A) >= 0:
        for i in range(N - 1):
            if A[i] > A[i + 1]:
                max_a = max(A)
                ind = A.index(max_a)
                A[i + 1] += max_a
                ans.append((ind + 1, i + 2))
    else:
        for i in range(N - 1, 0, -1):
            if A[i - 1] > A[i]:
                min_a = min(A)
                ind = A.index(min_a)
                A[i - 1] += min_a
                ans.append((ind + 1, i))

    print((len(ans)))
    for x, y in ans:
        print((x, y))

    # print(A)


def __starting_point():
    main()

__starting_point()

N = int(input())
A = list(map(int,input().split()))
amax = 0
ind = -1
for i in range(N):
    if abs(A[i])>amax:
        amax = abs(A[i])
        ind = i
if amax==0:
    print(0)
else:
    m = 2*N-2
    B = []
    if A[ind]>=0:
        for i in range(N):
            if i!=ind:
                B.append((ind+1,i+1))
        for i in range(N-1):
            B.append((i+1,i+2))
    else:
        for i in range(N):
            if i!=ind:
                B.append((ind+1,i+1))
        for i in range(N,1,-1):
            B.append((i,i-1))
    print(m)
    for i in range(m):
        print(B[i][0],B[i][1])

N = int(input())
A = list(map(int, input().split()))
mi, ma = min(A), max(A)
print(2*N)
if abs(mi)<=ma:
    k = A.index(ma)
    print(k+1,1)
    print(k+1,1)
    for i in range(N-1):
        print(i+1,i+2)
        print(i+1,i+2)
else:
    k = A.index(mi)
    print(k+1,N)
    print(k+1,N)
    for i in reversed(range(N-1)):
        print(i+2,i+1)
        print(i+2,i+1)

n = int(input())
b = list(map(int, input().split()))

a = sorted(b)

a.sort()

max_i = 0
min_i = 0
maxv = -1<<60
minv = 1<<60
for i in range(n):
    if maxv < b[i]:
        maxv = b[i]
        max_i = i
    if minv > b[i]:
        minv = b[i]
        min_i = i

if (a[0] >= 0):
    print((n-1))
    for i in range(n-1):
        print((i+1,i+2))
elif (a[-1] <= 0):
    print((n-1))
    for i in reversed(list(range(n-1))):
        print((i+2,i+1))
elif (abs(a[0]) < abs(a[-1])):
    print((2*n-2))
    for i in range(n):
        if max_i == i:continue;
        print((max_i+1, i+1))
    for i in range(n-1):
        print((i+1,i+2))
else:
    print((2*n-2))
    for i in range(n):
        if min_i == i:continue;
        print((min_i+1, i+1))
    for i in reversed(list(range(n-1))):
        print((i+2,i+1))


N = int(input())
a = list(map(int, input().split()))

max1 = max(a)
min1 = min(a)

if min1 >= 0:
    print(N-1)
    for i in range(N-1):
        print(i+1, i+2)
elif max1 <= 0:
    print(N-1)
    for i in range(N-1):
        print(N-i, N-i-1)
else:
    if -min1 < max1:
        t = a.index(max1) + 1
        print(2*N - 1)
        for i in range(N):
            print(t, i+1)
        for i in range(N-1):
            print(i+1, i+2)
    else:
        t = a.index(min1) + 1
        print(2*N - 1)
        for i in range(N):
            print(t, i+1)
        for i in range(N-1):
            print(N-i, N-i-1)

n = int(input())
a = list(map(int,input().split()))
s = max(a)
sx = a.index(s)
t = min(a)
tx = a.index(t)
if t >= 0:
    print(n-1)
    for i in range(n-1):
        print(str(i+1) + " " + str(i+2))
elif s <= 0:
    print(n-1)
    for i in reversed(range(n-1)):
        print(str(i+2) + " " + str(i+1))
else:
    print(2*n-1)
    if abs(s) >= abs(t):
        for i in range(n):
            print(str(sx+1) + " " + str(i+1))
        for i in range(n-1):
            print(str(i+1) + " " + str(i+2))
    elif abs(s) < abs(t):
        for i in range(n):
            print(str(tx+1) + " " + str(i+1))
        for i in reversed(range(n-1)):
            print(str(i+2) + " " + str(i+1))

n=int(input())
a=list(map(int,input().split()))
if min(a)>=0:
    print((n-1))
    for i in range(1,n):
        print((i,i+1))
elif max(a)<0:
    print((n-1))
    for i in range(1,n)[::-1]:
        print((i+1,i))
else:
    m=min(a)
    M=max(a)
    if abs(M)>=abs(m):
        idx=a.index(M)
        cnt=0
        print((2*n-2))
        for i in range(2):
            print((idx+1,2))
        for i in range(2,n):
            print((i,i+1))
            print((i,i+1))
    else:
        idx=a.index(m)
        print((2*n-2))
        for i in range(2):
            print((idx+1,n-1))
        for i in range(2,n)[::-1]:
            print((i,i-1))
            print((i,i-1))


def main():
    import sys
    import numpy as np
    ikimasu = sys.stdin.buffer.readline
    ini = lambda: int(ins())
    ina = lambda: list(map(int, ikimasu().split()))
    ins = lambda: ikimasu().strip()
    
    n = ini()
    tmp = ina()
    num,index = 0,0
    for i in range(n):
        if(abs(tmp[i])>num):
            num,index = abs(tmp[i]),i
    print((2*n-2))
    if(tmp[index]<=0):
        for i in range(n):
            if(i!=index):
                print((index+1,i+1))
        for i in range(n,1,-1):
            print((i,i-1))
    else:
        for i in range(n):
            if(i!=index):
                print((index+1,i+1))
        for i in range(1,n):
            print((i,i+1))


        
        
        


    
        


        


    




















def __starting_point():
    main()

__starting_point()

N = int(input())
A = [int(i) for i in input().split()]

if min(A) >= 0:
    print((N-1))
    for i in range(N-1):
        print((i+1, i+2))
elif max(A) < 0:
    print((N-1))
    for i in range(N-1):
        print((N-i, N-1-i))
else:
    if max(A) >= abs(min(A)):
        print((2*N-1))
        for i in range(N):
            print((A.index(max(A))+1, i+1))
        for i in range(N-1):
            print((i+1, i+2))
    else:
        print((2*N-1))
        for i in range(N):
            print((A.index(min(A))+1, i+1))
        for i in range(N-1):
            print((N-i, N-1-i))


#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    A = LI()
    MAX = max(A)
    MIN = min(A)
    print(2*N-1)
    if abs(MAX)<abs(MIN):
        #全部負にする
        min_idx = A.index(MIN) + 1
        for i in range(1,N+1):
            print(min_idx, i)
        #累積和
        for i in range(2,N+1)[::-1]:
            print(i,i-1)
    else:
        #全部非負にする
        max_idx = A.index(MAX) + 1
        for i in range(1,N+1):
            print(max_idx, i)
        #累積和
        for i in range(1,N):
            print(i,i+1)


def __starting_point():
    main()

__starting_point()

n = int(input())

a = [int(x) for x in input().split()]

ma = max(a)
mi = min(a)

if(ma*mi < 0):
    print((2*n-1))
    if ma > -1*mi:
        for i in range(n):
            print((a.index(ma)+1, i+1))
        for i in range(n-1):
            print((i+1, i+2))
    else:
        for i in range(n):
            print((a.index(mi)+1, i+1))
        for i in range(n-1):
            print((n-i, n-i-1))
else:
    print((n-1))
    if(ma > 0):
        for i in range(n-1):
            print((i+1, i+2))
    else:
        for i in range(n-1):
            print((n-i, n-i-1))


N = int(input())
A = list(map(int, input().split()))

ans = []
mx = max(A)
mi = min(A)

if mx * mi < 0:
    if abs(mi) > abs(mx):
        x = A.index(mi)
        for y in range(N):
            if y == x:
                continue
            A[y] += mi
            ans.append((x, y))
    else:
        x = A.index(mx)
        for y in range(N):
            if x == y:
                continue
            A[y] += mx
            ans.append((x, y))

for i in range(N - 1)[::(-1)**(min(A) < 0)]:
    l, r = A[i], A[i + 1]

    if l > r:
        if r >= 0:
            A[i + 1] += l
            ans.append((i, i + 1))
        elif l <= 0:
            A[i] += r
            ans.append((i + 1, i))

print((len(ans)))
for x, y in ans:
    print((x + 1, y + 1))

if list(sorted(A)) != A:
    print(A)
    1 / 0


n = int(input())
alst = list(map(int, input().split()))
max_ = max(alst)
min_ = min(alst)
max_ind = alst.index(max_)
min_ind = alst.index(min_)
print(2 * n - 1)
if abs(max_) > abs(min_):
    for i in range(n):
        print(max_ind + 1, i + 1)
    for i in range(n - 1):
        print(i + 1, i + 2)
else:
    for i in range(n):
        print(min_ind + 1, i + 1)
    for i in range(n, 1, -1):
        print(i, i - 1)

import sys
readline = sys.stdin.readline

N = int(readline())
A = list(map(int,readline().split()))

# 最も絶対値の大きい数を、それが正の数なら右から、負の数なら左から、
# 昇順になっていない場所に足していく

# print(A)

ans = []
plusmax = 0
minusmax = 0
plusmax_i = -1
minusmax_i = -1
  
target = -1
maxdiff = 0
for i in range(len(A)):
  if A[i] < minusmax:
    minusmax = A[i]
    minusmax_i = i
  if A[i] > plusmax:
    plusmax = A[i]
    plusmax_i = i
# 最も絶対値が大きいものが正であれば、左から順に足していく
# 負であれば右から
# この方針は途中で変えない。正なら最後まで正。
# 2要素の差の最大値は、絶対値の最大がたとえば1000のときに1000～-1000の差なので、
# 2回足せば必ず差が埋まる
  
if abs(plusmax) > abs(minusmax):
  # 正でいく場合
  maxval = plusmax
  max_i = plusmax_i
  for i in range(1,len(A)):
    if A[i - 1] > A[i]:
      ans.append((max_i + 1,i + 1))
      ans.append((max_i + 1,i + 1))
      A[i] += 2 * maxval
      max_i = i
      maxval = A[i]
else:
  # 負でいく場合
  minval = minusmax
  min_i = minusmax_i
  for i in range(len(A) - 1, 0,-1):
    if A[i - 1] > A[i]:
      ans.append((min_i + 1, i))
      ans.append((min_i + 1, i))
      A[i - 1] += 2 * minval
      min_i = i - 1
      minval = A[i - 1]
        
print((len(ans)))
for a in ans:
  print((*a))


N=int(input())
A=list(map(int, input().split()))
if min(A)>=0:
  print((N-1))
  for i in range(1,N):
    print((i,i+1))
elif max(A)<=0:
  print((N-1))
  for i in range(N-1):
    print((N-i,N-1-i))
else:
  a,b=max(A),abs(min(A))
  print(((N-1)*2))
  if a>=b:
    d=A.index(a)
    for i in range(N):
      if i!=d:
        print((d+1,i+1))
    for i in range(1,N):
      print((i,i+1))
  else:
    d=A.index(-b)
    for i in range(N):
      if i!=d:
        print((d+1,i+1))
    for i in range(N-1):
      print((N-i,N-1-i))


import sys
import math
import collections
import bisect
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list([int(x) - 1 for x in sys.stdin.readline().rstrip().split()])


# ===CODE===

def main():
    n = ni()
    a = na()

    min_num = min(a)
    min_num_idx = a.index(min_num)
    max_num = max(a)
    max_num_idx = a.index(max_num)
    ans = []

    plus_flg = abs(max_num) > abs(min_num)

    if plus_flg:
        for i in range(n - 1):
            while a[i] > a[i + 1]:
                a[i + 1] += max_num
                ans.append((max_num_idx, i + 1))
            if max_num < a[i + 1]:
                max_num_idx = i + 1
                max_num = a[i + 1]

    else:
        for i in range(n - 1, 0, -1):
            while a[i - 1] > a[i]:
                a[i - 1] += min_num
                ans.append((min_num_idx, i - 1))
            if min_num > a[i - 1]:
                min_num_idx = i - 1
                min_num = a[i - 1]

    print((len(ans)))
    for a, b in ans:
        print((a + 1, b + 1))


def __starting_point():
    main()

__starting_point()

import sys

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

# N <= 50
if A == sorted(A):
    print(0)
    return

min_a = (float("inf"), -1)
max_a = (-float("inf"), -1)
for i in range(N):
    if A[i] < min_a[0]:
        min_a = (A[i], i)
    if A[i] > max_a[0]:
        max_a = (A[i], i)

# 操作履歴
ops = []
# マイナスに寄せる
if abs(min_a[0]) > abs(max_a[0]):
    for i in range(N-1, -1, -1):
        # 高々2回
        while A[i] > min_a[0]:
            A[i] += min_a[0]
            ops.append((min_a[1]+1, i+1))
        min_a = (A[i], i)
        
else:
    for i in range(N):
        # 高々2回
        while A[i] < max_a[0]:
            A[i] += max_a[0]
            ops.append((max_a[1]+1, i+1))
        max_a = (A[i], i)
# print(A)

print(len(ops))
for (x, y) in ops:
    print(x, y)

N = int(input())
A = list(map(int, input().split()))
Amax = max(A)
Amin = min(A)

print(N*2)
if abs(Amax) > abs(Amin):
    Amaxi = A.index(Amax)+1
    print(Amaxi, 1)
    print(Amaxi, 1)
    for i in range(1, N):
        print(i, i+1)
        print(i, i+1)

else:
    Amini = A.index(Amin)+1
    print(Amini, N)
    print(Amini, N)
    for i in range(N, 1, -1):
        print(i, i-1)
        print(i, i-1)

N = int(input())
A = list(map(int,input().split()))
mx = max(A)
mxi = A.index(mx)
mn = min(A)
mni = A.index(mn)

ans = []
if mn >= 0 or mx + mn >= 0:
    for i in range(N):
        if A[i] < 0:
            ans.append((mxi, i))
    for i in range(N-1):
        ans.append((i, i+1))
else:
    for i in range(N):
        if A[i] > 0:
            ans.append((mni, i))
    for i in range(N-1,0,-1):
        ans.append((i, i-1))

print(len(ans))
for a,b in ans:
    print(a+1, b+1)

#!python3

# input
N = int(input())
A = list(map(int, input().split()))


def main():
    mx = max(A)
    mn = min(A)
    idx = A.index(mn) if abs(mx) < abs(mn) else A.index(mx)
    idx += 1
    ans = []
    for i in range(N):
        ans.append((idx, i + 1))
    
    if A[idx - 1] > 0:
        for i in range(1, N):
            ans.append((i, i + 1))
    else:
        for i in range(N - 1, 0, -1):
            ans.append((i + 1, i))
    
    n = len(ans)
    print(n)
    for i in range(n):
        print((*ans[i]))


def __starting_point():
    main()

__starting_point()

import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()
A = inl()
amax = max(A)
imax = A.index(amax)
amin = min(A)
imin = A.index(amin)


def make_positive():
    nonlocal amax, imax
    ans = []
    assert amax >= 0
    for i in range(N):
        if i > 0 and A[i] < 0:
            ans.append((imax, i))
            A[i] += amax
            assert A[i] >= 0
    for i in range(1, N):
        if A[i] < A[i - 1]:
            ans.append((imax, i))
            A[i] += amax
            assert A[i] >= A[i - 1]
            if A[i] > amax:
                amax = A[i]
                imax = i
    assert len(ans) <= 2 * N
    print(len(ans))
    for x, y in ans:
        print(x + 1, y + 1)


def make_negative():
    nonlocal amin, imin
    ans = []
    assert amin <= 0
    for i in range(N):
        if i < N - 1 and A[i] > 0:
            ans.append((imin, i))
            A[i] += amin
            assert A[i] <= 0
    for i in range(N - 2, -1, -1):
        if A[i] > A[i + 1]:
            ans.append((imin, i))
            A[i] += amin
            assert A[i] <= A[i + 1]
            if A[i] < amin:
                amin = A[i]
                imin = i
    assert len(ans) <= 2 * N
    print(len(ans))
    for x, y in ans:
        print(x + 1, y + 1)


def solve():
    if abs(amax) > abs(amin):
        make_positive()
    else:
        make_negative()
    return


solve()


import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())

command = []

plus_max = max(As)
minus_min = min(As)
if abs(plus_max)>=abs(minus_min):
    maxi_idx = As.index(plus_max)
    for i in range(N):
        a = As[i]
        if a<0:
            As[i] += plus_max
            command.append((i, maxi_idx))
    for i in range(N-1):
        a = As[i]
        b = As[i+1]
        if a>=0 and a>b:
            command.append((i+1, i))
            As[i+1] += As[i]
else:
    mini_idx = As.index(minus_min)
    for i in range(N):
        a = As[i]
        if a>0:
            As[i] += minus_min
            command.append((i, mini_idx))
    for i in range(N-1, 0, -1):
        a = As[i]
        b = As[i-1]
        if a<0 and b>a:
            command.append((i-1, i))
            As[i-1] += As[i]
print(len(command))
for x, y in command:
    print(y+1, x+1)

n = int(input())
A = list(int(x) for x in input().split())
minimum = min(A)
maximum = max(A)

ANS = []
if abs(maximum) >= abs(minimum):  # すべてをプラスにして累積和
    index = A.index(maximum)
    for i in range(n):
        ANS.append((index, i))
        # A[i] += maximum
    for i in range(n - 1):
        ANS.append((i, i + 1))
        # A[i+1] += A[i]
else:  # 最小値がマイナスで絶対値がかなり大きい -> n回ですべてをマイナスにして累積和
    index = A.index(minimum)
    for i in range(n):
        ANS.append((index, i))
        # A[i] += minimum
    for i in reversed(list(range(1, n))):
        ANS.append((i, i - 1))
        # A[i-1] += A[i]

print((len(ANS)))
for x, y in ANS:
    print((x + 1, y + 1))  # 1-index

# print(A)


N=int(input())
A = list(map(int,input().split()))
maxA = max(A)
minA = min(A)
flag = (abs(maxA) >= abs(minA))
cnt =0
man = []
if flag:
    idx = A.index(maxA)
    for i in range(len(A)):
        if i !=idx:
            man.append([idx+1,i+1])
    for i in range(1,len(A)):
        man.append([i,i+1])

else:
    idx = A.index(minA)
    for i in range(len(A)):
        if i !=idx:
            man.append([idx+1,i+1])
    for i in range(len(A),1,-1):
        man.append([i,i-1])
print((len(man)))
for ma in man:
    print((*ma))



N = int(input())
A = list(map(int, input().split()))

# 1例を示せ、なので、操作しないで良い場合も操作することにする

p = 0
m = 0
for i in range(N):
    if A[i] >= 0:
        p += 1
    else:
        m += 1


# 全部正なので左から累積和
ans = []
if m == 0:
    for i in range(N-1):
        ans.append((i+1, i+2))
    print(len(ans))
    for x,y in ans:
        print(x,y)
# 全部負なので左から累積和
elif p == 0:
    for i in range(N-1, 0, -1):
        ans.append((i+1, i))
    print(len(ans))
    for x,y in ans:
        print(x,y)
else:
    # 絶対値の大きい方で実施
    big = -1 * float("inf")
    big_idx = 0
    small = float("inf")
    small_idx = 0
    for i in range(N):
        if big < A[i]:
            big = A[i]
            big_idx = i

        if small > A[i]:
            small = A[i]
            small_idx = i

    # 全体を正にしてから左から累積和
    if abs(big) >= abs(small): 
        for i in range(N):
            if A[i] < 0:
                ans.append((big_idx+1, i+1))

        for i in range(N-1):
            ans.append((i+1, i+2))
        print(len(ans))
        for x,y in ans:
            print(x,y)
    # 全体を負にしてから右から累積和
    else:
        for i in range(N):
            if A[i] > 0:
                ans.append((small_idx+1, i+1))
        for i in range(N-1, 0, -1):
            ans.append((i+1, i))
        print(len(ans))
        for x,y in ans:
            print(x,y)

N, = list(map(int, input().split()))
As = list(map(int, input().split()))
a,b = max(As), min(As)
ai = As.index(a)
bi = As.index(b)
print((N-1+N-1))
if a > -b:
    for i in range(N):
        if i != ai:
            print((ai+1, i+1))
    for i in range(N-1):
        print((i+1, i+2))
else:
    for i in range(N):
        if i != bi:
            print((bi+1, i+1))
    for i in range(N-1):
        print((N-i, N-i-1))


N = int(input())
As = list(map(int, input().split()))

pair =[(a,i) for i,a in enumerate(As)]
pair.sort()
min_info = pair[0]
max_info = pair[-1]
# maxとminの大小関係からせめて見る
# minの絶対値が大きい->負で構成
# それ以外 -> 正で構成
print((2*N-1))
if abs(min_info[0]) > abs(max_info[0]):
    ind = pair[0][1]
    for i in range(N):
        print((ind+1, i+1))
    for i in range(N-1,0,-1):
        print((i+1,i))
else:
    ind = pair[-1][1]
    for i in range(N):
        print((ind+1, i+1))
    for i in range(1,N):
        print((i,i+1))


ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("YES") if fl else print("NO")
ips = lambda:input().split()
import collections
import math
import itertools
import heapq as hq
import sys


n = ni()
A = lma()
mx = 0
ans=[]
pal=1
idx=0
for i in range(n):
    if mx<abs(A[i]):
        mx=abs(A[i])
        pal=A[i]//mx
        idx=i
if pal==1:
    for i in range(n):
        if i==idx:continue
        ans.append((idx+1,i+1))
    for i in range(n-1):
        ans.append((i+1,i+2))
else:
    for i in range(n):
        if i==idx:continue
        ans.append((idx+1,i+1))
    for i in range(n-1,0,-1):
        ans.append((i+1,i))
print(len(ans))
for x,y in ans:
    print(x,y)


def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

#############
# Main Code #
#############

"""
N <= 50
単調増加になるように
いい方法を考える

全てプラス　前から累積
全てマイナス　後ろから累積

プラスとマイナス
全部プラスにするか全部マイナスにするか
プラスのとマイナスのどちらが大きいか

プラスのが大きい
マイナス部分を全てプラスに→前から累積
マイナスのが大きい
プラス部分を全てマイナスに→後ろから累積
det = [-1, 1]
place = [0, 0]
for i in range(N):
    if A[i] > det[0]:
        det[0] = A[i]
        place[0] = i
    elif A[i] < det[1]:
        det[1] = A[i]
        place[1] = i

if abs(det[0]) >= abs(det[1]):
    for i in range(N):
        A[i] += det[0]
    for i in range(1, N):
        A[i] += A[i - 1]
else:
    for i in range(N):
        A[i] += det[1]
    for i in range(N - 2, -1, -1):
        A[i] += A[i + 1]

print(A)
"""

N = getN()
A = getList()

det = [-1, 1]
place = [0, 0]
for i in range(N):
    if A[i] > det[0]:
        det[0] = A[i]
        place[0] = i
    elif A[i] < det[1]:
        det[1] = A[i]
        place[1] = i

# xをyに足す
print(2 * N - 1)
if abs(det[0]) >= abs(det[1]):
    for i in range(N):
        print(place[0] + 1, i + 1)
    for i in range(1, N):
        print(i, i + 1)
else:
    for i in range(N):
        print(place[1] + 1, i + 1)
    for i in range(N - 2, -1, -1):
        print(i + 2, i + 1)

n = int(input())
A = list(map(int, input().split()))
M = max(A)
m = min(A)
M_idx = A.index(M) + 1
m_idx = A.index(m) + 1
print(2*n-1)
if abs(M) >= abs(m):
  for i in range(1, n+1):
    print(M_idx, i)
  for i in range(1, n):
    print(i, i+1)
else:
  for i in range(1, n+1):
    print(m_idx, i)
  for i in range(n-1, 0, -1):
    print(i+1, i)

n=int(input())
a=list(map(int,input().split()))
ma=max(a)
mai=a.index(ma)
mi=min(a)
mii=a.index(mi)
ans=[]
if abs(ma)>=abs(mi):
  for i in range(n):
    a[i]+=ma
    ans.append((mai+1,i+1))
  for i in range(1,n):
    a[i]+=a[i-1]
    ans.append((i,i+1))
else:
  for i in range(n):
    a[i]+=mi
    ans.append((mii+1,i+1))
  for i in range(n-2,-1,-1):
    a[i]+=a[i+1]
    ans.append((i+2,i+1))
print(len(ans))
for i in ans:print(*i)

N = int(input())
a = list(map(int, input().split()))
if abs(max(a)) >= abs(min(a)):
    for i in range(N):
        if a[i] == max(a):
            num = i
            break
    print(2*N-1)
    for i in range(N):
        if num != i:
            print(num+1, i+1)
    print(num+1, num+1)
    for i in range(1,N):
        print(i, i+1)
else:
    for i in range(N):
        if a[i] == min(a):
            num = i
            break
    print(2*N-1)
    for i in range(N):
        if num != i:
            print(num+1, i+1)
    print(num+1, num+1)
    for i in range(N-1):
        print(N-i, N-i-1)

N = int(input())
A = list(map(int,input().split()))
flag = 0
for i in range(N):
    if A[i]!=0:
        flag = 1
        break
if flag==0:
    print(0)
else:
    pmax = 0
    mmin = 0
    indp = -1
    indm = -1
    for i in range(N):
        if A[i]>0:
            if A[i]>pmax:
                pmax = A[i]
                indp = i
        elif A[i]<0:
            if A[i]<mmin:
                mmin = A[i]
                indm = i
    if pmax>=abs(mmin):
        print(2*N-2)
        for i in range(N):
            if i!=indp:
                print(indp+1,i+1)
        for i in range(N-1):
            print(i+1,i+2)
    else:
        print(2*N-2)
        for i in range(N):
            if i!=indm:
                print(indm+1,i+1)
        for i in range(N-1,0,-1):
            print(i+1,i)

"""
まずは、全部正の数にするか、負の数にする
"""
N = int(input())
A = list(map(int,input().split()))
print((2*N-1))
if abs(max(A)) >= abs(min(A)):
    idx = A.index(max(A))+1
    for i in range(1,N+1):
        print((idx,i))
    for i in range(1,N):
        print((i,i+1))
else:
    idx = A.index(min(A))+1
    for i in range(1,N+1):
        print((idx,i))
    for i in range(N,1,-1):
        print((i,i-1))


from copy import copy
N = int(input())
A = list(map(int,(input().split())))

A.insert(0,-10000000)
B = copy(A)
ans = []
bns = []

for i in range(1,N):
    if A[i] > A[i+1]:
        if A[i] >= 0 and A[i+1] >= 0:
            A[i+1] += A[i]
            ans.append([i,i+1])
        elif A[i] <= 0 and A[i+1] <= 0:
            A[i] += A[i+1]
            ans.append([i+1,i])
        else:
            if abs(A[i]) <= abs(A[i+1]):
                A[i] += A[i+1]
                ans.append([i+1,i])
                A[i] += A[i+1]
                ans.append([i+1,i])
            else:
                A[i+1] += A[i]
                ans.append([i,i+1])
                A[i+1] += A[i]
                ans.append([i,i+1])
for i in range(1,N)[::-1]:
    if A[i] > A[i+1]:
        if A[i] >= 0 and A[i+1] >= 0:
            A[i+1] += A[i]
            ans.append([i,i+1])
        elif A[i] <= 0 and A[i+1] <= 0:
            A[i] += A[i+1]
            ans.append([i+1,i])
        else:
            if abs(A[i]) <= abs(A[i+1]):
                A[i] += A[i+1]
                ans.append([i+1,i])
                A[i] += A[i+1]
                ans.append([i+1,i])
            else:
                A[i+1] += A[i]
                ans.append([i,i+1])
                A[i+1] += A[i]
                ans.append([i,i+1])

A = B
for i in range(1,N)[::-1]:
    if A[i] > A[i+1]:
        if A[i] >= 0 and A[i+1] >= 0:
            A[i+1] += A[i]
            bns.append([i,i+1])
        elif A[i] <= 0 and A[i+1] <= 0:
            A[i] += A[i+1]
            bns.append([i+1,i])
        else:
            if abs(A[i]) <= abs(A[i+1]):
                A[i] += A[i+1]
                bns.append([i+1,i])
                A[i] += A[i+1]
                bns.append([i+1,i])
            else:
                A[i+1] += A[i]
                bns.append([i,i+1])
                A[i+1] += A[i]
                bns.append([i,i+1])
for i in range(1,N):
    if A[i] > A[i+1]:
        if A[i] >= 0 and A[i+1] >= 0:
            A[i+1] += A[i]
            bns.append([i,i+1])
        elif A[i] <= 0 and A[i+1] <= 0:
            A[i] += A[i+1]
            bns.append([i+1,i])
        else:
            if abs(A[i]) <= abs(A[i+1]):
                A[i] += A[i+1]
                bns.append([i+1,i])
                A[i] += A[i+1]
                bns.append([i+1,i])
            else:
                A[i+1] += A[i]
                bns.append([i,i+1])
                A[i+1] += A[i]
                bns.append([i,i+1])

M = len(ans)
L = len(bns)
if M <= L:
    print(M)
    for i in range(M):
        print(*ans[i])
else:
    print(L)
    for i in range(L):
        print(*bns[i])

inpl = lambda: list(map(int,input().split()))
N = int(input())
a = inpl()
ans = []
c = []
l, r = 0, N-1
while l < r:
    if a[l] <= 0:
        c.append((0,l))
        l += 1
        continue
    elif a[r] >= 0:
        c.append((1,r))
        r -= 1
        continue
    elif a[l] + a[r] <= 0:
        c.append((0,l))
        ans.append((r+1, l+1))
        l += 1
    else:
        c.append((1,r))
        ans.append((l+1, r+1))
        r -= 1

for s, b in c[::-1]:
    if s == 0:
        ans.append((b+2, b+1))
    else:
        ans.append((b, b+1))

print(len(ans))
for x, y in ans:
    print(x, y)

n=int(input())
arr=list(map(int,input().split()))
arr=[[arr[i],i+1] for i in range(n)]
mins=[10**18,0]
maxs=[-10**18,0]
flag=True
for i in range(n):
  if arr[i][0]<mins[0]:
    mins=[arr[i][0],arr[i][1]]
  if arr[i][0]>maxs[0]:
    maxs=[arr[i][0],arr[i][1]]
cnt=0
ans=[]
if maxs[0]<0:
  for i in range(n):
    flag=False
elif mins[0]>=0:
  pass
else:
  if abs(mins[0])>maxs[0]:
    flag=False
    for i in range(n):
      if arr[i][0]>0:
        arr[i][0]+=mins[0]
        cnt+=1
        ans.append([mins[1],arr[i][1]])
  else:
    for i in range(n):
      if arr[i][0]<0:
        arr[i][0]+=maxs[0]
        cnt+=1
        ans.append([maxs[1],arr[i][1]])
rows=[]
tmp=[[arr[0][0],arr[0][1]]]
for i in range(1,n):
  if arr[i-1][0]<=arr[i][0]:
    tmp.append([arr[i][0],arr[i][1]])
  else:
    rows.append(tmp)
    tmp=[[arr[i][0],arr[i][1]]]
if len(tmp)!=0:
  rows.append(tmp)
if flag==True:
  for i in range(len(rows)-1):
    if len(rows[i])==1:
      if len(rows[i+1])==1:
        rows[i+1][0][0]+=rows[i][0][0]
        ans.append([rows[i][0][1],rows[i+1][0][1]])
  for i in range(len(rows)-1):
    if len(rows[i])==1:
      if len(rows[i+1])==1:
        continue
      else:
        for j in range(len(rows[i+1])):
          rows[i+1][j][0]+=rows[i][0][0]
          ans.append([rows[i][0][1],rows[i+1][j][1]])
    else:
      if len(rows[i+1])==1:
        for j in range(i+1,len(rows)):
          if len(rows[j])==1:
            rows[j][0][0]+=rows[i][-1][0]
            ans.append([rows[i][-1][1],rows[j][0][1]])
          else:
            break
      else:
        for j in range(len(rows[i+1])):
          rows[i+1][j][0]+=rows[i][-1][0]
          ans.append([rows[i][-1][1],rows[i+1][j][1]])
else:
  for i in range(len(rows)-1,0,-1):
    if len(rows[i])==1:
      if len(rows[i-1])==1:
        rows[i-1][0][0]+=rows[i][0][0]
        ans.append([rows[i][0][1],rows[i-1][0][1]])
  for i in range(len(rows)-1,0,-1):
    if len(rows[i])==1:
      if len(rows[i-1])==1:
        continue
      else:
        for j in range(len(rows[i-1])):
          rows[i-1][j][0]+=rows[i][0][0]
          ans.append([rows[i][0][1],rows[i-1][j][1]])
    else:
      if len(rows[i-1])==1:
        for j in range(i-1,-1,-1):
          if len(rows[j])==1:
            rows[j][0][0]+=rows[i][0][0]
            ans.append([rows[i][0][1],rows[j][0][1]])
          else:
            break
      else:
        for j in range(len(rows[i-1])):
          rows[i-1][j][0]+=rows[i][0][0]
          ans.append([rows[i][0][1],rows[i-1][j][1]])
print(len(ans))
for i in range(len(ans)):
  print(*ans[i])

import math
#import sys
#input = sys.stdin.readline

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ZipArray(a):
    aa = [[a[i],i]for i in range(n)]

    aa.sort(key = lambda x : x[0])
    for i in range(n):
        aa[i][0]=i+1
    aa.sort(key = lambda x : x[1])
    b=[aa[i][0] for i in range(len(a))]
    return b

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans

def Zeros(a,b):
    if(b<=-1):
        return [0 for i in range(a)]
    else:
        return [[0 for i in range(b)] for i in range(a)]

def AddV2(v,w):
    return [v[0]+w[0],v[1]+w[1]]

dir4 = [[1,0],[0,1],[-1,0],[0,-1]]


def clamp(x,y,z):
    return max(y,min(z,x))

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
            
#
def Zaatsu(a):
    a.sort()
    now = a[0][0]
    od = 0
    for i in range(n):
        if(now==a[i][0]):
            a[i][0]=od
        else:
            now = a[i][0]
            od+=1
            a[i][0] = od
    
    a.sort(key = lambda x : x[1])
    return a

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)


'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 2
N = 10 ** 6 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

'''

def rl(x):
    return list(range(len(x)))

# a = list(map(int, input().split()))

#################################################
#################################################
#################################################
#################################################



#20-

n = int(input())

a= list(map(int, input().split()))

if(abs(max(a)) >= abs(min(a))):
    idx = -1
    mx = -1
    for i in range(n):
        if(mx<=a[i]):
            idx = i+1
            mx = a[i]
            
    print((n*2))
    print((idx,n))
    print((idx,n))
    for i in range(n-1):
        print((n,i+1))
        print((n,n))

else:
    idx = -1
    mi = 1
    for i in range(n):
        if(mi>=a[i]):
            idx = i+1
            mi = a[i]
            
    print((n*2))
    print((idx,1))
    print((idx,1))
    for i in range(n,1,-1):
        print((1,i))
        print((1,1))













































































N = int(input())
A = list(map(int,input().split()))

ans = []
def f1():
  for i in range(1,N):
    mx = -(10**7)
    mxi = 0
    for j in range(N):
      if A[j] > mx:
        mx = A[j]
        mxi = j
    A[i] += mx
    ans.append((mxi,i))
def f2():
  for i in range(N-2,-1,-1):
    mn = 10**7
    mni = 0
    for j in range(N):
      if A[j] < mn:
        mn = A[j]
        mni = j
    A[i] += mn
    ans.append((mni,i))

mx = -(10**7)
mxi = 0
mn = 10**7
mni = 0
for i in range(N):
  if A[i] > mx:
    mx = A[i]
    mxi = i
  if A[i] < mn:
    mn = A[i]
    mni = i
if mn >= 0:
  f1()
elif mx <= 0:
  f2()
elif mx >= abs(mn):
  for i in range(N):
    if A[i] < 0:
      A[i] += mx
      ans.append((mxi,i))
  f1()
else:
  for i in range(N):
    if A[i] > 0:
      A[i] += mn
      ans.append((mni,i))
  f2()

print((len(ans)))
for a1,a2 in ans:
  print((a1+1,a2+1))


import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

def my_sign(x):
    return (x > 0) - (x < 0)

N = I()
a = III()

max_val = 0
max_sign = 0
max_index = -1
for i,a0 in enumerate(a):
    if abs(a0)>max_val:
        max_val = abs(a0)
        max_sign = my_sign(a0)
        max_index = i

if max_sign==0:
    print(0)
elif max_sign==1:
    print(2*N-1)
    for i in range(N):
        print(max_index+1,i+1)
    for i in range(N-1):
        print(i+1,i+2)
else:
    print(2*N-1)
    for i in range(N):
        print(max_index+1,i+1)
    for i in range(1,N)[::-1]:
        print(i+1,i)

n=int(input())
arr=list(map(int,input().split()))
arr=[[arr[i],i+1] for i in range(n)]
mins=10**18
minpos=0
maxs=-10**18
maxpos=0
for i in range(n):
  a=arr[i][0]
  if a<mins:
    mins=a
    minpos=i+1
  if maxs<a:
    maxs=a
    maxpos=i+1
ans=[]
if maxs<=0:
  flag=False
elif mins>=0:
  flag=True
else:
  if maxs>=abs(mins):
    flag=True
    for i in range(n):
      arr[i][0]+=maxs
      ans.append([maxpos,arr[i][1]])
  else:
    flag=False
    for i in range(n):
      arr[i][0]+=mins
      ans.append([minpos,arr[i][1]])
if flag==True:
  for i in range(1,n):
    ans.append([i,i+1])
else:
  for i in range(n,1,-1):
    ans.append([i,i-1])
print(len(ans))
for i in range(len(ans)):
  print(*ans[i])

import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())
A = list(map(int, input().split()))
minv, maxv = min(A), max(A)
mini, maxi = -1, -1

for i in range(N):
    if minv == A[i]:
        mini = i
    if maxv == A[i]:
        maxi = i

if minv * maxv >= 0:
    print((N - 1))
    if minv >= 0:
        for i in range(N - 1):
            print((i + 1, i + 2))
    else:
        for i in range(N, 1, -1):
            print((i, i - 1))
else:
    print((2 * N - 1))
    if abs(minv) < abs(maxv):
        for i in range(N):
            print((maxi + 1, i + 1))
        for i in range(N - 1):
            print((i + 1, i + 2))
    else:
        for i in range(N):
            print((mini + 1, i + 1))
        for i in range(N, 1, -1):
            print((i, i - 1))


import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return list(map(int, input().split()))
def read_index(): return [int(x) - 1 for x in input().split()]
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    N = int(input())
    A = read_list()
    M = max(A)
    m = min(A)

    T = M if abs(M) >= abs(m) else m
    i = A.index(T) + 1
    ans = []
    if T >= 0:
        for j, a in enumerate(A):
            if a < 0:
                ans.append((i, j + 1))
        for i in range(N - 1):
            ans.append((i + 1, i + 2))
    else:
        for j, a in enumerate(A):
            if a > 0:
                ans.append((i, j + 1))
        for i in range(N - 1, 0, -1):
            ans.append((i + 1, i))


    print((len(ans)))
    for a, b in ans:
        A[b - 1] += A[a - 1]
        print((a, b))


def __starting_point():
    main()


__starting_point()

N = int(input())
*A, = list(map(int, input().split()))
mx = -float('inf')
mn = float('inf')
mxi = mni = -1
for i, a in enumerate(A, 1):
    if mx < a:
        mx, mxi = a, i
    if mn > a:
        mn, mni = a, i
ans = []
if abs(mx) >= abs(mn):
    for i in range(1, N+1):
        if i == mxi: continue
        ans.append(f'{mxi} {i}')
    for i in range(1, N):
        ans.append(f'{i} {i+1}')
else:
    for i in range(1, N+1):
        if i == mni: continue
        ans.append(f'{mni} {i}')
    for i in range(N, 1, -1):
        ans.append(f'{i} {i-1}')
print((len(ans)))
print(('\n'.join(map(str, ans))))


import sys
input=sys.stdin.readline

n=int(input())
a=list(map(int,input().split()))

m=a[0]
mi=0
for i in range(n):
    if abs(a[i])>abs(m):
        m=a[i]
        mi=i

print((2*n-1))
for i in range(n):
    print((mi+1,i+1))

if m>=0:
    for i in range(n-1):
        print((i+1,i+2))
else:
    for i in range(n-1):
        print((n-i,n-1-i))



n = int(input())
A = [int(i) for i in input().split()]

ans = []
_max = max(A)
_min = min(A)
_min_ptr = A.index(_min)
_max_ptr = A.index(_max)
if _min == _max:
    print((0))
    return

if sorted(A) == A:
    print((0))
    return

if _max < 0:
    for i in range(n - 1, 0, -1):
        A[i - 1] += A[i]
        ans.append((i, i - 1))

elif _min >= 0:
    for i in range(0, n - 1):
        A[i + 1] += A[i]
        ans.append((i, i + 1))

elif _min < 0 and _max >= 0 and abs(_min) > abs(_max):
    for i in range(n):
        if A[i] >= 0:
            A[i] += _min
            ans.append((_min_ptr, i))
    for i in range(n - 1, 0, -1):
        A[i - 1] += A[i]
        ans.append((i, i - 1))

elif _min < 0 and _max >= 4 and abs(_min) <= abs(_max):
    for i in range(n):
        if A[i] < 0:
            A[i] += _max
            ans.append((_max_ptr, i))
    for i in range(0, n - 1):
        A[i + 1] += A[i]
        ans.append((i, i + 1))


if len(ans) == 0:
    print((0))
    return

print((len(ans)))
for i, j in ans:
    print((i + 1, j + 1))


N = int(input())
A = list(map(int,input().split()))

if all(a==0 for a in A):
    print(0)
    return

INF = float('inf')
mn = INF
mx = -INF
mni = mxi = -1
for i,a in enumerate(A):
    if a > mx:
        mx = a
        mxi = i
    if a < mn:
        mn = a
        mni = i

ans = []
if mn >= 0:
    p = True
elif mx <= 0:
    p = False
else:
    if mx > -mn:
        for i,a in enumerate(A):
            if a < 0:
                ans.append((mxi+1, i+1))
        p = True
    else:
        for i,a in enumerate(A):
            if a > 0:
                ans.append((mni+1, i+1))
        p = False

if p:
    for i in range(1,N):
        ans.append((i,i+1))
else:
    for i in range(N,1,-1):
        ans.append((i,i-1))

print(len(ans))
for a,b in ans:
    print(a,b)

ans = 0
N = int(input())
A = list(map(int, input().split()))
ans = []
M = -float('inf')
m = float('inf')
for i in range(N):
  if A[i]>M:
    M_ind = i+1
    M = A[i]
  if A[i]<m:
    m_ind = i+1
    m = A[i]
if M*m<0:
  for i in range(N):
    if M>=abs(m):
      if i+1!= M_ind:
        ans.append([M_ind,i+1])
        A[i] += M
    else:
      if i+1!= m_ind:
        ans.append([m_ind,i+1])
        A[i] += m
if max(A)>0:
  for i in range(1,N):
    ans.append([i,i+1])
else:
  for i in range(N,1,-1):
    ans.append([i,i-1])
print(len(ans))
for a in ans:
  print(*a)

import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
mx = max(a)
mn = min(a)
res = []
if abs(mx) >= abs(mn):
  t = 0
  for i in range(N):
    if a[i] == mx:
      t = i
      break
  for i in range(N):
    res.append((t + 1, i + 1))
    a[i] += a[t]
  for i in range(N):
    for j in range(N):
      if a[j] > a[t]: t = j
    res.append((t + 1, i + 1))
    a[i] += a[t]
  print(len(res))
  for r in res: print(*r)
else:
  t = 0
  for i in range(N):
    if a[i] == mn:
      t = i
      break
  for i in range(N):
    res.append((t + 1, i + 1))
    a[i] += a[t]
  for i in range(N - 1, -1, -1):
    for j in range(N):
      if a[j] < a[t]: t = j
    res.append((t + 1, i + 1))
    a[i] += a[t]
  print(len(res))
  for r in res: print(*r)

import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    a = list(map(int, readline().split()))

    ans = []
    MAX = max(a); MIN = min(a)
    if MIN >= 0:
        for i in range(1, N):
            ans.append((i, i + 1))
    elif MAX <= 0:
        for i in reversed(list(range(1, N))):
            ans.append((i + 1, i))
    elif MAX > -MIN:
        max_idx = a.index(MAX)
        for i in range(N):
            if a[i] < 0:
                ans.append((max_idx + 1, i + 1))
        for i in range(1, N):
            ans.append((i, i + 1))
    else:
        min_idx = a.index(MIN)
        for i in range(N):
            if a[i] > 0:
                ans.append((min_idx + 1, i + 1))
        for i in reversed(list(range(1, N))):
            ans.append((i + 1, i))

    print((len(ans)))
    for i, j in ans:
        print((i, j))

def __starting_point():
   main()

__starting_point()

N = int(input())
a = list(map(int, input().split()))
m = 10**18
M = -10**18
m_idx = -1
M_idx = -1

for i in range(N):
    if a[i]<m:
        m = a[i]
        m_idx = i
    
    if a[i]>M:
        M = a[i]
        M_idx = i
        
ope = []

if abs(m)<=abs(M):
    for i in range(N):
        ope.append((M_idx, i))
    
    for i in range(N-1):
        ope.append((i, i+1))
else:
    for i in range(N):
        ope.append((m_idx, i))
    
    for i in range(N-1, 0, -1):
        ope.append((i, i-1))
    
print(len(ope))

for x, y in ope:
    print(x+1, y+1)

import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
mx = -float("inf")
mn = float("inf")
mxi = 0
mni = 0
for i in range(N):
  x = a[i]
  if mx < x:
    mx = x
    mxi = i
  if mn > x:
    mn = x
    mni = i
print(2 * N - 1)
if abs(mx) > abs(mn):
  for i in range(N): print(mxi + 1, i + 1)
  for i in range(N - 1): print(i + 1, i + 2)
else:
  for i in range(N): print(mni + 1, i + 1)
  for i in range(N - 1, 0, -1): print(i + 1, i)

n = int(input())
a = list(map(int, input().split()))
print(n * 2 - 1)
ma, mi = max(a), min(a)
ima, imi = a.index(ma), a.index(mi)
if abs(ma) >= abs(mi):
    for i in range(1, n + 1):
        print(ima + 1, i)
    for i in range(1, n):
        print(i, i + 1)
else:
    for i in range(1, n + 1):
        print(imi + 1, i)
    for i in range(1, n)[::-1]:
        print(i + 1, i)

from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      list(map(int, input().split()))
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = inl()
mx = max([abs(x) for x in a])
p = [i for i in range(n) if abs(a[i])==mx][0]
seq = []
if a[p]>0:
    for i in range(1,n):
        while a[i-1]>a[i]:
            a[i] += a[p]
            seq.append((p,i))
        if a[i]>a[p]:
            p = i
elif a[p]<0:
    for i in range(n-2,-1,-1):
        while a[i]>a[i+1]:
            a[i] += a[p]
            seq.append((p,i))
        if a[i]<a[p]:
            p = i
print((len(seq)))
for a,b in seq:
    print(("{} {}".format(a+1,b+1)))


n=int(input())
a=list(map(int,input().split()))
mxn=0
mnn=0
mx=-10**10
mn=10**10
for i in range(n):
  if mx<a[i]:
    mx=a[i]
    mxn=i
  if mn>a[i]:
    mn=a[i]
    mnn=i
print(2*n-1)
if mx+mn>=0:
  for i in range(n):
    print(mxn+1,i+1)
  for i in range(1,n):
    print(i,i+1)
else:
  for i in range(n):
    print(mnn+1,i+1)
  for i in range(n,1,-1):
    print(i,i-1)

import sys
sys.setrecursionlimit(10 ** 8)
def getnum(t=int): return t(sys.stdin.buffer.readline())
def numline(t=int): return list(map(t, sys.stdin.buffer.readline().split()))
def numread(t=int): return list(map(t, sys.stdin.buffer.read().split()))
def getstr(): return sys.stdin.readline().strip()
def strline(): return sys.stdin.readline().strip().split()
def strread(): return sys.stdin.read().strip().split()

# from numba import njit, b1, i4, i8, f8, jit
# import numpy as np
mod = 998_244_353

import math

def fromleft(N):
    for i in range(1, N):
        print((i, i+1))

def fromright(N):
    for i in range(N, 1, -1):
        print((i, i-1))


def main():
    N, *A = numread()
    A = [(a, i) for i, a in enumerate(A, 1)]
    (minA, mini), (maxA, maxi) = min(A, key = lambda x:x[0]), max(A, key = lambda x:x[0])
    if minA > 0:
        print((N-1))
        fromleft(N)
        return
    elif maxA <= 0:
        print((N-1))
        fromright(N)
        return
    elif abs(minA) > abs(maxA):
        print((2 * N - 1))
        for i in range(1, N+1):
            print((mini, i))
        fromright(N)
        return
    else:
        print((2 * N - 1))
        for i in range(1, N+1):
            print((maxi, i))
        fromleft(N)
        return



def __starting_point():
    main()

__starting_point()

from collections import defaultdict

N = int(input())
a = list(map(int, input().split()))
idx = defaultdict(int)

for i in range(N):
    idx[a[i]] = i
    
m = min(a)
M = max(a)
ans = []

if abs(M)>abs(m):
    for i in range(N):
        ans.append((idx[M], i))
    
    for i in range(1, N):
        ans.append((i-1, i))
else:
    for i in range(N):
        ans.append((idx[m], i))
    
    for i in range(N-2, -1, -1):
        ans.append((i+1, i))

print((len(ans)))

for x, y in ans:
    print((x+1, y+1))


n = int(input())
lis = list(map(int,input().split()))
AngeKatrina = 0
LizeHelesta = 0
for i,InuiToko in list(enumerate(lis)):
  if InuiToko >= 0:
    if InuiToko >= AngeKatrina:
      AngeKatrina = InuiToko
      AngeSoko = i+1
  else:
    if -InuiToko >= LizeHelesta:
      LizeHelesta = -InuiToko
      LizeHiyoko = i+1
print(2*n-1)
if AngeKatrina >= LizeHelesta:
  for i in range(1,n+1):
    print(AngeSoko,i)
  for i in range(1,n):
    print(i,i+1)
else:
  for i in range(1,n+1):
    print(LizeHiyoko,i)
  for i in range(n,1,-1):
    print(i,i-1)

n = int(input())
a = list(map(int, input().split()))
ans = []
mx = 0
for i in range(n):
    if abs(a[i])>abs(mx):
        mx = a[i]
        mx_idx = i
for i in range(n):
    if mx*a[i]<0:
        ans.append((mx_idx+1, i+1))
for i in range(n-1):
    if mx>0:
        ans.append((i+1, i+2))
    elif mx<0:
        ans.append((n-i, n-i-1))
print(len(ans))
for x, y in ans:
    print(x, y)

# ARC086_B Non Decreasing
def nonDecreasing(N, A):
    Amin = min(A)
    Amax = max(A)
    Amin_index = A.index(Amin)+1
    Amax_index = A.index(Amax)+1

    res = []

    # 右をどんどん増やしていく
    # Amaxは正の数のはず
    if abs(Amax) > abs(Amin):
        for i in range(1, N):
            while A[i - 1] > A[i]:
                A[i] += Amax
                res.append((Amax_index, i+1))
                if A[i] > Amax:
                    Amax = A[i]
                    Amax_index = i+1

    # 左をどんどん減らしていく
    # Aminは負の数のはず
    else:
        for i in range(N - 1, 0, -1):
            while A[i - 1] > A[i]:
                A[i - 1] += Amin
                res.append((Amin_index, i))
                if A[i - 1] < Amin:
                    Amin = A[i - 1]
                    Amin_index = i
    return res


def __starting_point():
    N = int(input())
    A = list(map(int, input().split()))
    ans = nonDecreasing(N, A)

    print((len(ans)))
    for a in ans:
        print((*a))

__starting_point()

N = int(input())
A = list(map(int,input().split()))
cmax = 0
a = 0
ind = -1
for i in range(N):
    if abs(A[i])>cmax:
        cmax = abs(A[i])
        a = A[i]
        ind = i
if a>0:
    B = []
    for i in range(N):
        if A[i]<0:
            A[i] += a
            B.append([ind+1,i+1])
    for i in range(1,N):
        A[i] += A[i-1]
        B.append([i,i+1])
    print(len(B))
    for j in range(len(B)):
        print(*B[j])
elif a<0:
    B = []
    for i in range(N):
        if A[i]>0:
            A[i] += a
            B.append([ind+1,i+1])
    for i in range(N-2,-1,-1):
        A[i] += A[i+1]
        B.append([i+2,i+1])
    print(len(B))
    for j in range(len(B)):
        print(*B[j])
else:
    print(0)

n = int(input())
a = list(map(int, input().split()))

mx_i = 0
for i, e in enumerate(a):
    if abs(e) > abs(a[mx_i]):
        mx_i = i

ans = []
for i in range(n):
    if i == mx_i:
        continue
    a[i] += a[mx_i]
    ans.append([mx_i + 1, i + 1])

if a[mx_i] > 0:
    for i in range(n - 1):
        if a[i] > a[i+1]:
            a[i+1] += a[i]
            ans.append([i + 1, i + 2])

else:
    for i in range(n - 1, 0, -1):
        if a[i] < a[i-1]:
            a[i-1] += a[i]
            ans.append([i + 1, i])

print((len(ans)))
for row in ans:
    print((*row))


n = int(input())
a = list(map(int,input().split()))

print((2*n - 2))

M = a.index(max(a))
m = a.index(min(a))
if abs(a[m]) <= abs(a[M]):
    for i in range(n):
        if i != M:
            print((M+1,i+1))
    for i in range(n-1):
        print((i+1,i+2))
else:
    for i in range(n):
        if i != m:
            print((m+1,i+1))
    for i in range(1,n)[::-1]:
        print((i+1,i))


n = int(input())
a = [int(i) for i in input().split()]

a_max=max(a)
i_max=a.index(a_max) + 1
a_min=min(a)
i_min=a.index(a_min) + 1
ans=[]

if a_min>=0:
    print((n-1))
    for i in range(1,n):
        print((i,i+1))
elif a_max<0:
    print((n-1))
    for i in range(n,1,-1):
        print((i,i-1))
elif abs(a_max)>abs(a_min):
    print((2*n-2))
    for i in range(1,n+1):
        if i != i_max:
            print((i_max,i))

    for i in range(1,n):
        print((i,i+1))

else:
    print((2*n-2))
    for i in range(1,n+1):
        if i != i_min:
            print((i_min,i))
    for i in range(n,1,-1):
        print((i,i-1))


N = int(input())
A = list(map(int,input().split()))
amin = min(A)
indmin = A.index(amin)+1
amax = max(A)
indmax = A.index(amax)+1
if amin>=0:
    print((N-1))
    for i in range(1,N):
        print((i,i+1))
elif amax<=0:
    print((N-1))
    for i in range(N,1,-1):
        print((i,i-1))
elif amax+amin>=0:
    print((2*(N-1)))
    for i in range(1,N+1):
        if i!=indmax:
            print((indmax,i))
    for i in range(1,N):
        print((i,i+1))
elif amax+amin<0:
    print((2*(N-1)))
    for i in range(1,N+1):
        if i!=indmin:
            print((indmin,i))
    for i in range(N,1,-1):
        print((i,i-1))


n=int(input())
l=list(map(int,input().split()))
m=min(l)
ma=max(l)
print((2*n-1))
if m<0 and abs(m)>abs(ma):
    idx=l.index(m)+1
    for i in range(1,n+1):
        print((idx,i))
    for i in range(n-1,0,-1):
        print((i+1,i))
else:
    idx=l.index(ma)+1
    for i in range(1,n+1):
        print((idx,i))
    for i in range(2,n+1):
        print((i-1,i))
        



N = int(input())
A = list(map(int,input().split()))

MIN,MAX = 10**7,-10**7
ans = []
for i in range(N):
    if MIN > A[i]:
        MIN =A[i]
        min_i = i
    if MAX < A[i]:
        MAX = A[i]
        max_i = i

if abs(MIN) <= abs(MAX):
    for i in range(N):
        if A[i] < 0:
            A[i] += MAX
            ans.append([max_i+1,i+1])
    # print(A)

    for i in range(N-1):
        if A[i] > A[i+1]:
            A[i+1] += A[i]
            ans.append([i+1,i+2])

else:
    for i in range(N):
        if A[i] > 0:
            A[i] += MIN
            ans.append([min_i+1,i+1])
    # print(A)

    for i in range(N-1,0,-1):
        if A[i] < A[i-1]:
            A[i-1] += A[i]
            ans.append([i+1,i])
print((len(ans)))
for a in ans:
    print((*a))






N=int(input())
A=list(map(int,input().split()))

m=0
index=-1
for i in range(0,N):
    if abs(A[i])>m:
        m=abs(A[i])
        index=i

if index==-1:
    print(0)
else:
    if A[index]>0:
        operate=[]
        for i in range(0,N):
            if i!=index:
                operate.append((index+1,i+1))
                A[i]+=A[index]

        for i in range(0,N-1):
            if A[i]>A[i+1]:
                operate.append((i+1,i+2))
                A[i+1]+=A[i]

        print(len(operate))
        for x,y in operate:
            print(x,y)
    else:
        operate=[]
        for i in range(0,N):
            if i!=index:
                operate.append((index+1,i+1))
                A[i]+=A[index]

        for i in range(N-1,0,-1):
            if A[i]<A[i-1]:
                operate.append((i+1,i))
                A[i-1]+=A[i]

        print(len(operate))
        for x,y in operate:
            print(x,y)

N = int(input())
a = list(map(int, input().split()))
cnt1 = 0
li1 = []
for i in range(1,N):
    M = max(a)
    num = 0
    for j in range(N):
        if a[j] == M:
            n = j
    if a[i] < a[i-1]:
        if M <= 0:
            cnt1= -1
            break
        num += -((-a[i-1]+a[i])//M)
        if num < 0 or num > 2*N:
            cnt1 = -1
            break
        a[i] += num*M
        for j in range(num):
            li1.append([n+1, i+1])
        cnt1 += num
cnt2 = 0
li2 = []
for i in range(1,N):
    M = min(a)
    num = 0
    for j in range(N):
        if a[j] == M:
            n = j
    if a[N-i] < a[N-i-1]:
        if M >= 0:
            cnt2 = -1
            break
        num += -((-a[N-i-1]+a[N-i])//(-M))
        if num < 0 or num > 2*N:
            cnt2 = -1
            break
        a[N-i-1] += num *M
        for j in range(num):
            li2.append([n+1, N-i])
        cnt2 += num
if cnt1 <= 2*N and cnt1 >= 0:
    print(cnt1)
    for x in li1:
        print(*x)
else:
    print(cnt2)
    for x in li2:
        print(*x)

#!/usr/bin python3
# -*- coding: utf-8 -*-

n = int(input())
a = list(map(int, input().split()))
m = 0
for i, ai in enumerate(a):
    if abs(ai) >= m:
        m = abs(ai)
        mi = i
ret= [[mi+1, i+1] for i in range(n)]
if a[mi] >= 0:
    for i in range(n-1):
        ret.append([i+1, i+2])
else:
    for i in range(n-2, -1, -1):
        ret.append([i+2, i+1])  #i+1->i
print((2*n-1))
for x in ret:
    print((" ".join(map(str, x))))


N = int(input())
a = list(map(int, input().split()))
m = min(a)
M = max(a)


flag = 1
plus = 0
minus = 0
for x in a:
    if x > 0:
        plus += 1
    elif x < 0:
        minus += 1
if m*M < 0:
    if m + M >= 0:
        id = a.index(M)
        print((minus + N-1))
        for i in range(N):
            if a[i] < 0:
                a[i] += M
                print((id+1, i+1))

    else:
        id = a.index(m)
        print((plus + N-1))
        for i in range(N):
            if a[i] > 0:
                a[i] += m
                print((id+1, i+1))

        flag = 0

else:
    print((N-1))
    if m < 0:
        flag = False


if flag:  # 正の数列
    # M = max(a)
    # id = a.index(M)
    for i in range(1, N):
        # if i == 0:
        #     a[i] += M
        #     print(id+1, 1)
        # else:
        a[i] += a[i-1]
        print((i, i+1))

else:
    # m = min(a)
    # id = a.index(m)
    for i in range(N-2, -1, -1):
        # if i == N-1:
        #     a[i] += m
        #     print(id, i+1)
        # else:
        a[i] += a[i+1]
        print((i+2, i+1))
# print(a)


n,*a=map(int,open(0).read().split())
ans=[str(2*n-1)]
if max(a)>-min(a):
	i=a.index(max(a))
	for k in range(n):
		ans.append("{} {}".format(i+1,k+1))
	for k in range(n-1):
		ans.append("{} {}".format(k+1,k+2))
else:
	i=a.index(min(a))
	for k in range(n):
		ans.append("{} {}".format(i+1,k+1))
	for k in range(n-1):
		ans.append("{} {}".format(n-k,n-k-1))
print("\n".join(ans))

N = int(input())
A = list(map(int,input().split()))
amax = max(A)
amin = min(A)
if amax+amin>=0:
    imax = A.index(amax)
    imax += 1
    m = 2*N-2
    print(m)
    for i in range(1,N+1):
        if i != imax:
            print(imax,i)
    for i in range(1,N):
        print(i,i+1)
else:
    imin = A.index(amin)
    imin += 1
    m = 2*N-2
    print(m)
    for i in range(1,N+1):
        if i!=imin:
            print(imin,i)
    for i in range(N,1,-1):
        print(i,i-1)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    if all([a > 0 for a in A]):
        print(N-1)
        for i in range(N-1):
            print(i+1,i+2)
        return
    elif all([a <= 0 for a in A]):
        print(N-1)
        for i in range(N-1,0,-1):
            print(i+1,i)
        return
    else:
        if abs(max(A)) >= abs(min(A)):
            print(2*N-1)
            for i in range(N):
                print(A.index(max(A)) + 1, i+1)
            for i in range(N-1):
                print(i+1,i+2)
            return
        else:
            print(2*N-1)
            for i in range(N):
                print(A.index(min(A))+1, i+1)            
            for i in range(N-1,0,-1):
                print(i+1,i)
            return


def __starting_point():
    main()
__starting_point()

import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()
M = max(a)
m = min(a)
ans = []

if m >= 0:
    for i in range(1,n):
        a[i] += a[i-1]
        ans.append((i,i+1))
else:
    if M <= 0:
        for i in range(n-1)[::-1]:
            a[i] += a[i+1]
            ans.append((i+2,i+1))
    else:
        if M > -m:
            Mi = a.index(M)
            for i in range(n):
                if a[i] < 0:
                    a[i]+=M
                    ans.append((Mi+1,i+1))
            for i in range(1,n):
                a[i] += a[i-1]
                ans.append((i,i+1))
        else:
            mi = a.index(m)
            for i in range(n):
                if a[i] > 0:
                    a[i]+=m
                    ans.append((mi+1,i+1))
            for i in range(n-1)[::-1]:
                a[i] += a[i+1]
                ans.append((i+2,i+1))

print(len(ans))
print('\n'.join([str(i)+' '+str(j) for i,j in ans]))

N = int(input())
A = list(map(int,input().split()))

if all(v>=0 for v in A):
    print((N-1))
    for i in range(1,N):
        print((i,i+1))
elif all(v<0 for v in A):
    print((N-1))
    for i in reversed(list(range(1,N))):
        print((i+1,i))
else:
    max_ind=A.index(max(A))+1
    min_ind = A.index(min(A))+1
    if abs(max(A))>=abs(min(A)):
        print((2*N-1))
        for i in range(1,N+1):
            print((max_ind,i))
        for i in range(1,N):
            print((i,i+1))
    else:
        print((2*N-1))
        for i in range(1,N+1):
            print((min_ind,i))
        for i in reversed(list(range(1,N))):
            print((i+1,i))



def main():

    N = int(input())
    A = list(map(int, input().split()))

    ans = []
    if min(A) >= 0:
        v = float('-inf')
        max_i = None
        for i in range(N):
            if A[i] > v:
                max_i = i
                v = A[i]

        ans.append([max_i, 0])
        for i in range(1, N):
            ans.append([i-1, i])
    elif max(A) <= 0:
        v = float('inf')
        min_i = None
        for i in range(N):
            if A[i] < v:
                min_i = i
                v = A[i]
        ans.append([min_i, N-1])
        for i in range(N-2, -1, -1):
            ans.append([i+1, i])
    elif abs(max(A)) >= abs(min(A)):
        v = float('-inf')
        max_i = None
        for i in range(N):
            if A[i] > v:
                max_i = i
                v = A[i]
        for i in range(N):
            if i != max_i:
                ans.append([max_i, i])
        ans.append([max_i, max_i])
        ans.append([max_i, 0])
        for i in range(1, N):
            ans.append([i-1, i])
    else:
        v = float('inf')
        min_i = None
        for i in range(N):
            if A[i] < v:
                min_i = i
                v = A[i]
        for i in range(N):
            if i != min_i:
                ans.append([min_i, i])
        ans.append([min_i, min_i])
        ans.append([min_i, N-1])
        for i in range(N-2, -1, -1):
            ans.append([i+1, i])

    print(len(ans))
    for i, j in ans:
        print(str(i+1) + " " + str(j+1))

def __starting_point():
    main()
__starting_point()

"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd"""
import sys
#input = sys.stdin.readline

import copy

N=int(input())
Amoto=list(map(int,input().split()))
lst=[]
A=copy.copy(Amoto)
_min=A[0]
minidx=0
for i in range(1,N):
    if _min>A[i]:
        _min=A[i]
        minidx=i
if _min<0:
    for i in range(N)[::-1]:
        while _min<A[i] and len(lst)<=2*N+1:
            A[i]+=_min
            lst.append([minidx+1,i+1])
        minidx=i
        _min=A[i]

    if  len(lst)<=2*N:
        print((len(lst)))
        for i in lst:
            print((" ".join([str(x) for x in i ])))
        return
A=copy.copy(Amoto)
_max=A[0]
maxidx=0
lst=[]
for i in range(1,N):
    if _max<A[i]:
        _max=A[i]
        maxidx=i
if _max>0:
    for i in range(N):
        while _max>A[i] and len(lst)<=2*N+1:
            A[i]+=_max
            lst.append([maxidx+1,i+1])
        maxidx=i
        _max=A[i]
    if  len(lst)<=2*N:
        print((len(lst)))
        for i in lst:
            print((" ".join([str(x) for x in i ])))
        return
else:
    print((0))


import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**7
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N = NI()
    A = LI()
    ans = []

    max_a = max(A)
    min_a = min(A)

    if max_a * min_a < 0:
        p = max_a if abs(max_a) > abs(min_a) else min_a
        q = A.index(p)
        for i in range(N):
            ans.append((q+1,i+1))
            A[i] += p
        min_a = min(A)

    if min_a >= 0:
        for i in range(1,N):
            ans.append((i,i+1))
    else:
        for i in range(N,1,-1):
            ans.append((i,i-1))

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

def __starting_point():
    main()
__starting_point()

N = int(input())
A = list(map(int,input().split()))

tmp = 0
disc = 0
for i, a in enumerate(A):
  if abs(tmp) < abs(a):
    tmp = a
    disc = i

print(2*N-2)
for i in range(N):
  if i == disc: continue
  print(disc+1, i+1)
if tmp >= 0:
  for i in range(N-1):
    print(i+1, i+1+1)
else:
  for i in range(N-1,0,-1):
    print(i+1, i+1-1)

#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	A = getlist()
	M = max(A)
	p = A.index(M)
	m = min(A)
	q = A.index(m)
	if m >= 0:
		print(N - 1)
		for i in range(N - 1):
			print(i + 1, i + 2)
	else:
		if abs(M) > abs(m):
			print(2 * N - 1)
			for i in range(N):
				print(p + 1, i + 1)
			for i in range(N - 1):
				print(i + 1, i + 2)
		else:
			print(2 * N - 1)
			for i in range(N):
				print(q + 1, i + 1)
			for i in range(N - 1):
				print(N - i, N - 1 - i)

def __starting_point():
	main()
__starting_point()

n = int(input())
a = list(map(int, input().split()))
b, idx = list(zip(*sorted(zip(a, list(range(1, n + 1))))))
if b[-1] < 0:
    print((n - 1))
    # 全て負の数なので後ろから累積和をとる
    for i in range(n - 1):
        print((n - i, n - i - 1))
elif b[0] >= 0:
    print((n - 1))
    for i in range(n - 1):
        print((i + 1, i + 2))
else:
    # max or min を足して全て正の数に直す
    print((2 * n - 2))
    if b[-1] > abs(b[0]):
        # add max
        for i in range(n):
            if i + 1 != idx[-1]:
                print((idx[-1], i + 1))
        for i in range(n - 1):
            print((i + 1, i + 2))
    else:
        for i in range(n):
            if i + 1 != idx[0]:
                print((idx[0], i + 1))
        for i in range(n - 1):
            print((n - i, n - i - 1))


# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(N, A):
    mxi = -1
    mxa = 0
    for i, a in enumerate(A):
        if abs(a) >= abs(mxa):
            mxa = a
            mxi = i
    ans = []
    for i in range(N):
        if A[i] * mxa < 0:
            ans.append((mxi + 1, i + 1))
            A[i] += mxa
    if mxa > 0:
        for i in range(1, N):
            if A[i] < A[i - 1]:
                ans.append((i, i + 1))
                A[i] += A[i - 1]
    else:
        for i in range(N - 2, -1, -1):
            if A[i] > A[i + 1]:
                ans.append((i + 2, i + 1))
                A[i] += A[i + 1]
    print((len(ans)))
    for a in ans:
        print((*a))

def __starting_point():
    input = sys.stdin.readline
    N = int(input())
    *A, = list(map(int, input().split()))
    main(N, A)

__starting_point()

# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,*a = map(int, read().split())
idx = max(range(n),key=lambda i: abs(a[i]))

print(2*n-1)
for i in range(n):
    print(idx+1,i+1)
if a[idx] >= 0:
    for i in range(n-1):
        print(i+1,i+2)
else:
    for i in range(n-2,-1,-1):
        print(i+2,i+1)

def construct(is_reversed=False):
    start, end, step = 0, N - 1, 1
    if is_reversed:
        start, end, step = N - 1, 0, -1
    ret = []
    for i in range(start, end, step):
        ret.append((i + 1, i + step + 1))
    return ret


def solve():
    max_A = max(A)
    min_A = min(A)
    if max_A == min_A:
        return []
    elif abs(max_A) >= abs(min_A):
        idx = A.index(max_A)
        return [(idx + 1, i + 1) for i in range(N) if i != idx] + construct()
    elif abs(max_A) < abs(min_A):
        idx = A.index(min_A)
        return [(idx + 1, i + 1) for i in range(N) if i != idx] + construct(True)


N = int(input())
A = list(map(int, input().split()))
ans = solve()
print((len(ans)))
for e in ans:
    print((*e))


n = int(input())
a = [int(i) for i in input().split()]
M = max(a)
m = min(a)
ans = []
if m >= 0:
    for i in range(1, n):
        a[i] += a[i - 1]
        ans.append([i, i + 1])
else:
    if M <= 0:
        for i in range(n - 1)[::-1]:
            a[i] += a[i + 1]
            ans.append([i + 2, i + 1])
    else:
        if M > -m:
            index = a.index(M)
            for i in range(n):
                if a[i] < 0:
                    a[i] += M
                    ans.append([index + 1, i + 1])
            for i in range(1, n):
                a[i] += a[i - 1]
                ans.append([i, i + 1])
        else:
            index = a.index(m)
            for i in range(n):
                if a[i] > 0:
                    a[i] += m
                    ans.append([index + 1, i + 1])
            for i in range(n - 1)[::-1]:
                a[i] += a[i + 1]
                ans.append([i + 2, i + 1])
print(len(ans))
print('\n'.join([str(i) + ' ' + str(j) for i, j in ans]))

# ARC086D

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))


n = int(input())
a = list(map(int, input().split()))

m = max([abs(item) for item in a if item<=0] + [0])
M = max([abs(item) for item in a if item>=0] + [0])

def sub(i, j, a):
    print(i, j)
    a[j-1] += a[i-1]
    
print(2*n-1)
if M >= m:
    ind = a.index(M)+1
    for i in range(1,n+1):
        if i==ind:
            continue
        sub(ind, i, a)
    sub(ind, 1, a)
    for i in range(1, n):
        sub(i, i+1, a)
else:
    ind = a.index(-m)+1
    for i in range(1,n+1):
        if i==ind:
            continue
        sub(ind, i, a)
    sub(ind, n, a)
    for i in range(n, 1, -1):
        sub(i, i-1, a)

n = int(input())
al = list(map(int, input().split()))

amax = -10**7
maxi = -1
amin = 10**7
mini = -1
for i, a in enumerate(al):
    if a > amax: 
        amax = a
        maxi = i
    if a < amin:
        amin = a
        mini = i

ansl = []
if amin >= 0 or amax >= abs(amin):
    print(2*n-1)
    for i in range(n):
        print(maxi+1,i+1)
    for i in range(n-1):
        print(i+1,i+2)

else:
    print(2*n-1)
    for i in range(n):
        print(mini+1, i+1)
    for i in range(n-1,0,-1):
        print(i+1,i)