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.

Source: atcoder | Difficulty: HARD


Solutions:
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))


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 queue
from collections import deque, defaultdict
import heapq as hpq
from sys import stdin, setrecursionlimit
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
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))


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)
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)
else:
	pass
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]))


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))

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)
elif -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))
elif 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
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)


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
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 16
MOD = 10 ** 9 + 7
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()])

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()))
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):
		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):
		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(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)


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('\x1b[33m', *a, '\x1b[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))
	for i in range(n - 1):
		ANS.append((i, i + 1))
else:
	index = A.index(minimum)
	for i in range(n):
		ANS.append((index, i))
	for i in reversed(list(range(1, n))):
		ANS.append((i, i - 1))
print(len(ANS))
for (x, y) in ANS:
	print((x + 1, y + 1))


N = int(input())
A = list(map(int, input().split()))
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]
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]
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
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])
		elif 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])
		elif 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])
		elif 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])
		elif 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
elif 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]])
		elif 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]])
		elif 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

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)
	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 rl(x):
	return list(range(len(x)))
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
elif 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
elif 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
		elif 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
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()
mod = 998244353
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
	elif -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)


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()))
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()))
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)
elif 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)


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])
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:
	for i in range(1, N):
		a[i] += a[i - 1]
		print((i, i + 1))
else:
	for i in range(N - 2, -1, -1):
		a[i] += a[i + 1]
		print((i + 2, i + 1))


(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
	elif 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))
elif M <= 0:
	for i in range(n - 1)[::-1]:
		a[i] += a[i + 1]
		ans.append((i + 2, i + 1))
elif 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()


import sys
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)
	elif 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:
	print(2 * n - 2)
	if b[-1] > abs(b[0]):
		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))


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)


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])
elif M <= 0:
	for i in range(n - 1)[::-1]:
		a[i] += a[i + 1]
		ans.append([i + 2, i + 1])
elif 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]))


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)