AtCoder Beginner Contest 081 - Non-decreasing

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.

Examples

Input

3
-2 5 -1


Output

2
2 3
3 3


Input

2
-1 -3


Output

1
2 1


Input

5
0 0 0 0 0


Output

0

Difficulty: UNKNOWN_DIFFICULTY

Starter code:

Solutions:
N = int(input())
A = list(map(int, input().split()))
mina = min(A)
mini = A.index(mina)
maxa = max(A)
maxi = A.index(maxa)
if mina >= 0:
	print(N - 1)
	for i in range(N - 1):
		print('{} {}'.format(i + 1, i + 2))
elif maxa < 0:
	print(N - 1)
	for i in range(N - 1):
		print('{} {}'.format(N - i, N - i - 1))
elif -mina < maxa:
	print(2 * N - 1)
	for i in range(N):
		print('{} {}'.format(maxi + 1, i + 1))
	for i in range(N - 1):
		print('{} {}'.format(i + 1, i + 2))
else:
	print(2 * N - 1)
	for i in range(N):
		print('{} {}'.format(mini + 1, i + 1))
	for i in range(N - 1):
		print('{} {}'.format(N - i, N - i - 1))


n = int(input())
a = list(map(int, input().split()))
mina = min(a)
maxa = max(a)
powa = maxa if abs(mina) < abs(maxa) else mina
powa_i = a.index(powa)
ansl = []
if powa < 0:
	for i in range(n):
		if a[i] >= 0:
			ansl.append(f'{powa_i + 1} {i + 1}')
	ansl.append(f'{powa_i + 1} {n}')
	for i in reversed(range(1, n)):
		ansl.append(f'{i + 1} {i}')
else:
	for i in range(n):
		if a[i] <= 0:
			ansl.append(f'{powa_i + 1} {i + 1}')
	ansl.append(f'{powa_i + 1} {1}')
	for i in range(1, n):
		ansl.append(f'{i} {i + 1}')
print(len(ansl))
print('\n'.join(ansl))


(n, *a) = map(int, open(0).read().split())
ans = []
if sum((t for t in a if t > 0)) > sum((-t for t in a if t < 0)):
	i = 0
	while a[i] < 0:
		i += 1
	for j in range(n):
		if a[j] > 0 and i != j:
			a[i] += a[j]
			ans += [(j + 1, i + 1)]
	for j in range(n):
		if a[j] < 0:
			a[j] += a[i]
			ans += [(i + 1, j + 1)]
	for i in range(1, n):
		ans += [(i, i + 1)]
else:
	i = 0
	while a[i] > 0:
		i += 1
	for j in range(n):
		if a[j] < 0 and i != j:
			a[i] += a[j]
			ans += [(j + 1, i + 1)]
	for j in range(n):
		if a[j] > 0:
			a[j] += a[i]
			ans += [(i + 1, j + 1)]
	for i in range(n, 1, -1):
		ans += [(i, i - 1)]
print(len(ans))
for t in ans:
	print(*t)


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


N = int(input())
A = [int(a) for a in input().split()]
ma = -1
mai = -1
for i in range(N):
	if abs(A[i]) > ma:
		ma = abs(A[i])
		mai = i
print(2 * N - 1)
for i in range(N):
	print(mai + 1, i + 1)
if A[mai] > 0:
	for i in range(N - 1):
		print(i + 1, i + 2)
else:
	for i in range(N - 1)[::-1]:
		print(i + 2, i + 1)


import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 5)

def li():
	return map(int, stdin.readline().split())

def li_():
	return map(lambda x: int(x) - 1, stdin.readline().split())

def lf():
	return map(float, stdin.readline().split())

def ls():
	return stdin.readline().split()

def ns():
	return stdin.readline().rstrip()

def lc():
	return list(ns())

def ni():
	return int(stdin.readline())

def nf():
	return float(stdin.readline())
n = ni()
a = list(li())
nml = 0
idx = -1
if abs(min(a)) > abs(max(a)):
	nml = min(a)
	idx = a.index(nml)
else:
	nml = max(a)
	idx = a.index(nml)
print(2 * n - 1)
for i in range(n):
	print(idx + 1, i + 1)
if nml < 0:
	for j in range(n, 1, -1):
		print(j, j - 1)
else:
	for j in range(1, n):
		print(j, j + 1)


(N, *A) = map(int, open(0).read().split())
v_max = max(A)
v_min = min(A)
flg1 = v_max > 0 and v_min >= 0
flg2 = v_max <= 0 and v_min <= 0
flg3 = v_max * v_min < 0 and abs(v_max) >= abs(v_min)
flg4 = v_max * v_min < 0 and abs(v_max) < abs(v_min)
s = sorted([(i + 1, v) for (i, v) in enumerate(A)], key=lambda x: x[1])
ans = []
if flg1 or flg3:
	if flg3:
		i_max = s[-1][0]
		for j in range(1, N + 1):
			ans.append((i_max, j))
	for j in range(1, N):
		ans.append((j, j + 1))
else:
	if flg4:
		i_min = s[0][0]
		for j in range(1, N + 1):
			ans.append((i_min, j))
	for j in reversed(range(1, N)):
		ans.append((j + 1, j))
print(len(ans))
for v in ans:
	print(*v)


N = int(input())
A = [int(a) for a in input().split()]
(maxi, maxA, mini, minA) = (0, A[0], 0, A[0])
for i in range(1, N):
	if A[i] > maxA:
		(maxi, maxA) = (i, A[i])
	if A[i] < minA:
		(mini, minA) = (i, A[i])
Ans = []
if abs(maxA) >= abs(minA):
	for i in range(N):
		if A[i] < 0:
			Ans.append((maxi + 1, i + 1))
			A[i] += maxA
	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):
		if A[i] > 0:
			Ans.append((mini + 1, i + 1))
			A[i] += minA
	for i in reversed(range(N - 1)):
		if A[i] > A[i + 1]:
			Ans.append((i + 2, i + 1))
			A[i] += A[i + 1]
print(len(Ans))
for (x, y) in Ans:
	print(x, y)


N = int(input())
A = [int(x) for x in input().split()]
(maxA, minA) = (max(A), min(A))
if maxA >= abs(minA):
	OP = [(A.index(maxA) + 1, i + 1) for i in range(N)] + [(i, i + 1) for i in range(1, N)]
else:
	OP = [(A.index(minA) + 1, i + 1) for i in range(N)] + [(i + 1, i) for i in reversed(range(1, N))]
print(len(OP))
for op in OP:
	print(*op)


import sys

def I():
	return int(sys.stdin.readline().rstrip())

def LI():
	return list(map(int, sys.stdin.readline().rstrip().split()))
N = I()
a = LI()
(M, m) = (max(a), min(a))
(b, c) = (a.index(M) + 1, a.index(m) + 1)
if M > 0 and m < 0:
	print(2 * N - 1)
	if M <= -m:
		for i in range(1, N + 1):
			a[i - 1] += m
			print(c, i)
	else:
		for i in range(1, N + 1):
			a[i - 1] += M
			print(b, i)
else:
	print(N - 1)
if max(a) <= 0:
	for i in range(N, 1, -1):
		print(i, i - 1)
else:
	for i in range(1, N):
		print(i, i + 1)


def main():
	(n, *a) = map(int, open(0).read().split())
	(p, q) = (min(a), max(a))
	if p == q:
		print(0)
		exit()
	x = []
	(f, g) = (a.index(p) + 1, a.index(q) + 1)
	if abs(p) > abs(q):
		for i in range(n):
			if a[i] > 0:
				x.append((f, i + 1))
		for i in range(n - 1):
			x.append((n - i, n - i - 1))
	else:
		for i in range(n):
			if a[i] < 0:
				x.append((g, i + 1))
		for i in range(n - 1):
			x.append((i + 1, i + 2))
	print(len(x))
	print('\n'.join(['{} {}'.format(i[0], i[1]) for i in x]))
main()


import sys
input = sys.stdin.buffer.readline

def main():
	N = int(input())
	A = list(map(int, input().split()))
	(a, b) = (max(A), min(A))
	(ap, bp) = (A.index(a), A.index(b))
	ans = []
	if a >= -b:
		for i in range(N):
			if A[i] < 0:
				A[i] += a
				ans.append([ap + 1, i + 1])
		for i in range(N - 1):
			A[i + 1] += A[i]
			ans.append([i + 1, i + 2])
	else:
		for i in range(N):
			if A[i] > 0:
				A[i] += b
				ans.append([bp + 1, i + 1])
		for i in range(N - 1):
			A[-i - 2] += A[-i - 1]
			ans.append([N - i, N - i - 1])
	L = len(ans)
	print(L)
	for i in range(L):
		print(*ans[i])
main()


N = int(input())
A = [int(x) for x in input().split()]
mi = 100000000
ma = -100000000
mi_n = 0
ma_n = 0
for i in range(N):
	if A[i] > ma:
		ma = A[i]
		ma_n = i + 1
	if A[i] < mi:
		mi = A[i]
		mi_n = i + 1
if mi >= 0:
	print(N - 1)
	for i in range(N - 1):
		print(i + 1, i + 2)
elif ma <= 0:
	print(N - 1)
	for i in range(N - 1):
		print(N - i, N - i - 1)
else:
	print(N + N - 1)
	if abs(ma) > abs(mi):
		for i in range(N):
			print(ma_n, i + 1)
		for j in range(N - 1):
			print(j + 1, j + 2)
	else:
		for i in range(N):
			print(mi_n, i + 1)
		for j in range(N - 1):
			print(N - j, N - j - 1)


N = int(input())
a = list(map(int, input().split()))
m = 0
manu = []
for i in range(1, N):
	if abs(a[m]) < abs(a[i]):
		m = i
for i in range(N):
	if a[m] * a[i] < 0:
		a[i] += a[m]
		manu.append([m, i])
if a[m] >= 0:
	for i in range(N - 1):
		if a[i] > a[i + 1]:
			a[i + 1] += a[i]
			manu.append([i, i + 1])
else:
	for i in range(N - 1):
		if a[N - i - 2] > a[N - i - 1]:
			a[N - i - 2] += a[N - i - 1]
			manu.append([N - i - 1, N - i - 2])
print(len(manu))
for i in range(len(manu)):
	manu[i][0] += 1
	manu[i][1] += 1
	print(' '.join(list(map(str, manu[i]))))


n = int(input())
ans = []
l = list(map(int, input().split()))
if min(l) >= 0:
	m = 1
if max(l) <= 0:
	m = -2
if max(l) > 0 and min(l) < 0:
	if max(l) >= -min(l):
		m = max(l)
	else:
		m = min(l)
	mi = l.index(m)
	for i in range(n):
		if m > 0:
			if l[i] < 0:
				ans.append([mi + 1, i + 1])
		elif l[i] > 0:
			ans.append([mi + 1, i + 1])
if m > 0:
	for i in range(n - 1):
		ans.append([i + 1, i + 2])
else:
	for i in range(n, 1, -1):
		ans.append([i, i - 1])
print(len(ans))
for i in ans:
	print(*i)


n = int(input())
a = list(map(int, input().split()))
a_max = -10 ** 7
a_max_idx = -1
a_min = 10 ** 7
a_max_idx = -1
for (i, ai) in enumerate(a):
	if a_max < ai:
		a_max = ai
		a_max_idx = i
	if a_min > ai:
		a_min = ai
		a_min_idx = i
operation = []
if abs(a_max) > abs(a_min):
	for (i, ai) in enumerate(a):
		if ai < 0:
			operation.append((a_max_idx + 1, i + 1))
	for i in range(1, n):
		operation.append((i, i + 1))
else:
	for (i, ai) in enumerate(a):
		if ai > 0:
			operation.append((a_min_idx + 1, i + 1))
	for i in reversed(range(1, n)):
		operation.append((i + 1, i))
print(len(operation))
for opi in operation:
	print(*opi)


n = int(input())
a = list(map(int, input().split()))
maxa = max(a)
mina = min(a)
if abs(mina) <= abs(maxa):
	idx = a.index(maxa)
	print(2 * (n - 1))
	pre = idx + 1
	for i in range(1, n):
		print(pre, i + 1)
		print(pre, i + 1)
		pre = i + 1
elif abs(mina) > abs(maxa):
	idx = a.index(mina)
	print(2 * (n - 1))
	pre = idx + 1
	for i in range(n - 1, 0, -1):
		print(pre, i)
		print(pre, i)
		pre = i


N = int(input())
a = list(map(int, input().split()))
ma = a[0]
mi = a[0]
maN = 0
miN = 0
for i in range(N):
	if a[i] > ma:
		ma = a[i]
		maN = i
	elif a[i] < mi:
		mi = a[i]
		miN = i
if abs(ma) > abs(mi):
	t = maN + 1
	f = 1
else:
	t = miN + 1
	f = -1
print(N * 2 - 1)
for i in range(1, N + 1):
	print(t, i)
if f == 1:
	for i in range(1, N):
		print(i, i + 1)
else:
	for i in range(N, 1, -1):
		print(i, i - 1)


N = int(input())
A = list(map(int, input().split()))
(MAX, MAX_index) = (0, 0)
positive_flg = True
for (i, a) in enumerate(A):
	if abs(a) > MAX:
		if a > 0:
			positive_flg = True
		else:
			positive_flg = False
		MAX = abs(a)
		MAX_index = i
ans = []
for i in range(N):
	ans.append((MAX_index, i))
if positive_flg:
	for i in range(N - 1):
		ans.append((i, i + 1))
else:
	for i in reversed(range(N - 1)):
		ans.append((i + 1, i))
print(len(ans))
for (x, y) in ans:
	print(x + 1, y + 1)


import sys
sys.setrecursionlimit(2147483647)
INF = float('inf')
MOD = 10 ** 9 + 7
input = lambda : sys.stdin.readline().rstrip()

def resolve():
	n = int(input())
	A = list(map(int, input().split()))
	m = min(A)
	M = max(A)
	mi = A.index(m) + 1
	Mi = A.index(M) + 1
	print(2 * n - 2)
	if -m <= M:
		for i in range(1, n + 1):
			if i == Mi:
				continue
			print(Mi, i)
		for i in range(1, n):
			print(i, i + 1)
	else:
		for i in range(1, n + 1):
			if i == mi:
				continue
			print(mi, i)
		for i in range(n, 1, -1):
			print(i, i - 1)
resolve()


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


N = int(input())
(*A,) = map(int, input().split())
(max_A, min_A) = (max(A), min(A))
(max_idx, min_idx) = (A.index(max_A), A.index(min_A))
mode = None
if min_A >= 0:
	mode = 2
elif max_A <= 0:
	mode = 3
elif max_A >= abs(min_A):
	mode = 0
else:
	mode = 1
actions = []
if mode == 0:
	for i in range(N):
		if i != max_idx:
			A[i] += A[max_idx]
			actions.append((max_idx + 1, i + 1))
	mode += 2
elif mode == 1:
	for i in range(N):
		if i != min_idx:
			A[i] += A[min_idx]
			actions.append((min_idx + 1, i + 1))
	mode += 2
if mode == 2:
	for i in range(N - 1):
		A[i + 1] += A[i]
		actions.append((i + 1, i + 2))
elif mode == 3:
	for i in range(N - 1, 0, -1):
		A[i - 1] += A[i]
		actions.append((i + 1, i))
print(len(actions))
for a in actions:
	print(*a)


n = int(input())
lists = list(map(int, input().split()))
maxi = 0
gives = 0
index = 0
for i in range(n):
	if abs(lists[i]) > maxi:
		maxi = abs(lists[i])
		gives = lists[i]
		index = i
if gives < 0:
	print(2 * n - 2)
	for i in range(n):
		if i != index:
			print(index + 1, i + 1)
	for i in range(n - 1):
		print(n - i, n - 1 - i)
elif gives >= 0:
	print(2 * n - 2)
	for i in range(n):
		if i != index:
			print(index + 1, i + 1)
	for i in range(n - 1):
		print(i + 1, i + 2)


N = int(input())
A = list(map(int, input().split()))
Ans = []
pre = -10 ** 9
maxi = A.index(max(A))
mini = A.index(min(A))
if abs(A[maxi]) > abs(A[mini]):
	for i in range(N):
		if i != maxi:
			Ans.append([maxi + 1, i + 1])
	for i in range(1, N):
		Ans.append([i, i + 1])
else:
	for i in range(N):
		if i != mini:
			Ans.append([mini + 1, i + 1])
	for i in range(N - 1, 0, -1):
		Ans.append([i + 1, i])
print(len(Ans))
for ans in Ans:
	print(*ans, sep=' ')


N = int(input())
A = list(map(int, input().split()))
(M, Mi) = (0, 0)
for (i, a) in enumerate(A):
	if abs(a) > abs(M):
		M = a
		Mi = i
ans = []
if M > 0:
	for i in range(N):
		ans.append((Mi, i))
		A[i] += A[Mi]
	for i in range(N - 1):
		if A[i] > A[i + 1]:
			ans.append((i, i + 1))
			A[i + 1] += A[i]
else:
	for i in range(N):
		ans.append((Mi, i))
		A[i] += A[Mi]
	for i in range(N - 1, 0, -1):
		if A[i - 1] > A[i]:
			ans.append((i, i - 1))
			A[i - 1] += A[i]
print(len(ans))
for (x, y) in ans:
	print(x + 1, y + 1)


N = int(input())
As = list(map(int, input().split()))
rs = []
n = max(range(N), key=lambda i: abs(As[i]))
for i in range(N):
	rs.append((n, i))
if As[n] > 0:
	for i in range(1, N):
		rs.append((i - 1, i))
if As[n] < 0:
	for i in reversed(range(1, N)):
		rs.append((i, i - 1))
print(len(rs))
for (x, y) in rs:
	print(x + 1, y + 1)


N = int(input())
A = [int(a) for a in input().split()]
ans = []
if abs(max(A)) > abs(min(A)):
	num = max(A)
	idx = A.index(num)
	for i in range(1, N):
		while A[i - 1] > A[i]:
			A[i] += num
			ans.append([str(idx + 1), str(i + 1)])
			if A[i] > num:
				num = A[i]
				idx = i
else:
	num = min(A)
	idx = A.index(num)
	for i in range(N - 2, -1, -1):
		while A[i] > A[i + 1]:
			A[i] += num
			ans.append([str(idx + 1), str(i + 1)])
			if A[i] < num:
				num = A[i]
				idx = i
m = len(ans)
print(m)
for i in range(m):
	print(' '.join(ans[i]))


N = int(input())
A = list(map(int, input().split()))
maxa = max(A)
mina = min(A)
print(2 * N - 1)
if abs(maxa) > abs(mina):
	k = A.index(maxa)
	for i in range(N):
		print(k + 1, i + 1)
		A[i] += A[k]
	for i in range(1, N):
		A[i] += A[i - 1]
		print(i, i + 1)
else:
	k = A.index(mina)
	for i in range(N):
		print(k + 1, i + 1)
		A[i] += A[k]
	for i in range(N, 1, -1):
		print(i, i - 1)
		A[i - 2] += A[i - 1]


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


N = int(input())
A = list(map(int, input().split()))
Amax = max(A)
Amin = min(A)
ans = []
if Amax >= -Amin:
	im = A.index(Amax) + 1
	i = 2
	while i <= N:
		if A[i - 2] > A[i - 1]:
			ans.append(str(im) + ' ' + str(i))
			A[i - 1] += Amax
			if Amax < A[i - 1]:
				im = i
				Amax = A[i - 1]
		else:
			i += 1
else:
	im = A.index(Amin) + 1
	i = N - 1
	while i >= 1:
		if A[i - 1] > A[i]:
			ans.append(str(im) + ' ' + str(i))
			A[i - 1] += Amin
			if Amin > A[i - 1]:
				im = i
				Amin = A[i - 1]
		else:
			i -= 1
print(len(ans))
for out in ans:
	print(out)


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


(N, *A) = map(int, open(0).read().split())
M = max(A)
m = min(A)
s = range(1, N + 1)
p = print
p(2 * N - 1)
(v, d) = -m < M and (M, 1) or (m, -1)
r = s[::d]
for i in s:
	p(A.index(v) + 1, i)
for z in zip(r, r[1:]):
	p(*z)


n = int(input())
a = list(map(lambda x: int(x), input().split()))
count = 0
ans = ''
max_num = max(a)
max_idx = a.index(max_num)
min_num = min(a)
min_idx = a.index(min_num)
if abs(max_num) >= abs(min_num):
	for i in range(len(a)):
		a[i] += max_num
		ans += '{} {}\n'.format(max_idx + 1, i + 1)
		count += 1
	for i in range(len(a) - 1):
		a[i + 1] += a[i]
		ans += '{} {}\n'.format(i + 1, i + 1 + 1)
		count += 1
else:
	for i in range(len(a)):
		a[i] += min_num
		ans += '{} {}\n'.format(min_idx + 1, i + 1)
		count += 1
	for i in range(len(a) - 1):
		a[len(a) - (i + 2)] += a[len(a) - (i + 1)]
		ans += '{} {}\n'.format(len(a) - (i + 1) + 1, len(a) - (i + 2) + 1)
		count += 1
print(count)
print(ans)


n = int(input())
a = list(map(int, input().split()))
amin = min(a)
amax = max(a)
imin = a.index(min(a)) + 1
imax = a.index(max(a)) + 1
if amin >= 0:
	print(n - 1)
	for i in range(1, n):
		print('{} {}'.format(i, i + 1))
	exit()
if amax <= 0:
	print(n - 1)
	for i in range(1, n):
		print('{} {}'.format(n - i + 1, n - i))
	exit()
print(2 * n - 1)
if abs(amin) <= abs(amax):
	for i in range(1, n + 1):
		print('{} {}'.format(imax, i))
	for i in range(1, n):
		print('{} {}'.format(i, i + 1))
	exit()
if abs(amin) >= abs(amax):
	for i in range(1, n + 1):
		print('{} {}'.format(imin, i))
	for i in range(1, n):
		print('{} {}'.format(n - i + 1, n - i))


import sys
N = int(input())
a_ls = list(map(int, input().split()))
Maxabs = 0
indofmaxabs = -1
for i in range(N):
	if Maxabs < abs(a_ls[i]):
		Maxabs = abs(a_ls[i])
		indofmaxabs = i
if Maxabs == 0:
	print(0)
	sys.exit()
print(2 * (N - 1))
for i in range(N):
	if not i == indofmaxabs:
		print(indofmaxabs + 1, i + 1)
if a_ls[indofmaxabs] >= 0:
	for i in range(N - 1):
		print(i + 1, i + 2)
else:
	for i in range(N - 1, 0, -1):
		print(i + 1, i)


def main():
	N = int(input())
	A = list(map(int, input().split()))
	r = []
	(ma, mi) = (max(A), min(A))
	if ma * mi < 0:
		if abs(mi) > abs(ma):
			ma = mi
		mi = A.index(ma)
		for (i, a) in enumerate(A):
			if ma * a < 0:
				r.append((mi, i))
				A[i] += ma
	if min(A) >= 0:
		for i in range(1, N):
			if A[i] < A[i - 1]:
				A[i] += A[i - 1]
				r.append((i - 1, i))
	else:
		for i in reversed(range(N - 1)):
			if A[i] > A[i + 1]:
				A[i] += A[i + 1]
				r.append((i + 1, i))
	print(len(r))
	for (rx, ry) in r:
		print(rx + 1, ry + 1)
main()


n = int(input())
a = list(map(int, input().split()))
ans = 0
a_max = max(a)
a_min = min(a)
if a_min >= 0:
	adding = a_max
elif a_min < 0 and a_max > 0:
	if abs(a_max) >= abs(a_min):
		adding = a_max
	else:
		adding = a_min
else:
	adding = a_min
ind = a.index(adding)
proc = []
for i in range(n):
	ans += 1
	a[i] += adding
	proc.append([ind + 1, i + 1])
if adding == a_max:
	for i in range(n - 1):
		ans += 1
		a[i + 1] += a[i]
		proc.append([i + 1, i + 2])
else:
	for i in range(n - 1):
		ans += 1
		a[-(i + 2)] += a[-(i + 1)]
		proc.append([n - i, n - i - 1])
print(ans)
for i in range(len(proc)):
	print(proc[i][0], proc[i][1])


N = int(input())
A = list(map(int, input().split()))
maxa = -float('inf')
mina = float('inf')
for (i, a) in enumerate(A):
	if maxa < a:
		maxa = a
		maxi = i
	if mina > a:
		mina = a
		mini = i
if abs(maxa) >= abs(mina):
	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, -1):
		print(i, i - 1)


N = int(input())
A = list(map(int, input().split()))
maxA = max(A)
minA = min(A)
argmax = -1
argmin = -1
print(2 * N - 1)
for i in range(N):
	if maxA == A[i]:
		argmax = i
	if minA == A[i]:
		argmin = i
if abs(maxA) >= abs(minA):
	for i in range(N):
		print(argmax + 1, i + 1)
	for i in range(N - 1):
		print(i + 1, i + 2)
else:
	for i in range(N):
		print(argmin + 1, i + 1)
	for i in range(N - 1):
		print(N - i, N - 1 - i)


n = int(input())
a = list(map(int, input().split()))
ans = []
if max(a) > -min(a):
	x = max(a)
	idx = 0
	for i in range(n):
		if a[i] == x:
			idx = i
			break
	for i in range(n):
		if a[i] == a[idx]:
			continue
		ans.append((idx + 1, i + 1))
	for i in range(n - 1):
		ans.append((i + 1, i + 2))
else:
	x = min(a)
	idx = 0
	for i in range(n):
		if a[i] == x:
			idx = i
			break
	for i in range(n):
		if a[i] == a[idx]:
			continue
		ans.append((idx + 1, i + 1))
	for i in range(n - 1)[::-1]:
		ans.append((i + 2, i + 1))
print(len(ans))
for i in ans:
	print(i[0], i[1])


n = int(input())
a = list(map(int, input().split()))
max_a = max(a)
min_a = min(a)
count = 0
ans = []
if abs(min_a) <= abs(max_a):
	max_i = 0
	for i in range(n):
		if a[i] == max_a:
			max_i = i
	for i in range(n):
		ans.append([max_i + 1, i + 1])
		count += 1
	for i in range(n - 1):
		ans.append([i + 1, i + 2])
		count += 1
else:
	min_i = 0
	for i in range(n):
		if a[i] == min_a:
			min_i = i
	for i in range(n):
		ans.append([min_i + 1, i + 1])
		count += 1
	for i in range(n - 1, 0, -1):
		ans.append([i + 1, i])
		count += 1
print(count)
for i in ans:
	print(*i)


def main():
	N = int(input())
	a = list(map(int, input().split()))
	amax = max(a)
	amin = min(a)
	OP = []
	if abs(amax) >= abs(amin):
		idx = a.index(amax) + 1
		OP += [(idx, i) for i in range(1, N + 1)]
		OP += [(i, i + 1) for i in range(1, N)]
	else:
		idx = a.index(amin) + 1
		OP += [(idx, i) for i in range(1, N + 1)]
		OP += [(i + 1, i) for i in reversed(range(1, N))]
	print(len(OP))
	for op in OP:
		print(*op)
main()


def d_non_decreasing(N, A):
	a_max = max(A)
	a_argmax = A.index(a_max) + 1
	a_min = min(A)
	a_argmin = A.index(a_min) + 1
	if abs(a_max) >= abs(a_min):
		plus_index = a_argmax
		cumsum_range = range(1, N)
		cumsum_direction = +1
	else:
		plus_index = a_argmin
		cumsum_range = range(N, 1, -1)
		cumsum_direction = -1
	ans = [str(2 * N - 1)]
	for k in range(1, N + 1):
		ans.append('{} {}'.format(plus_index, k))
	for k in cumsum_range:
		ans.append('{} {}'.format(k, k + cumsum_direction))
	ans = '\n'.join(ans)
	return ans
N = int(input())
A = [int(i) for i in input().split()]
print(d_non_decreasing(N, A))


import sys
line = sys.stdin.readline().strip()
N = int(line)
line = sys.stdin.readline().strip()
A = [int(x) for x in line.split()]
vs = sorted([(x, i) for (i, x) in enumerate(A)])
k = vs[0] if abs(vs[0][0]) > abs(vs[-1][0]) else vs[-1]
tejun = []

def mv(i, j):
	tejun.append((i, j))
	A[j] += A[i]
if k[0] > 0:
	mv(k[1], 0)
	mv(k[1], 0)
	for i in range(1, N):
		mv(i - 1, i)
		mv(i - 1, i)
elif k[0] < 0:
	mv(k[1], N - 1)
	mv(k[1], N - 1)
	for i in range(N, 1, -1):
		mv(i - 1, i - 2)
		mv(i - 1, i - 2)
else:
	pass
print(len(tejun))
for t in tejun:
	print(t[0] + 1, t[1] + 1)


(N, *A) = map(int, open(0).read().split())
M = max(A)
m = min(A)
ans = []
if -m < M:
	idx = A.index(M)
	for i in range(N):
		A[i] += A[idx]
		ans.append((idx, i))
	for i in range(1, N):
		A[i] += A[i - 1]
		ans.append((i - 1, i))
else:
	idx = A.index(m)
	for i in range(N):
		A[i] += A[idx]
		ans.append((idx, i))
	for i in range(N - 1, 0, -1):
		A[i - 1] += A[i]
		ans.append((i, i - 1))
print(len(ans))
for (x, y) in ans:
	print(x + 1, y + 1)


N = int(input())
A = [int(x) for x in input().split()]
(mn, mx) = (min(A), max(A))

def op(x, y):
	print(x, y)
	print(x, y)
	A[y - 1] += A[x - 1]
	A[y - 1] += A[x - 1]
print(N * 2)
if abs(mn) < abs(mx):
	base = mx
	bi = A.index(base) + 1
	op(bi, 1)
	for i in range(N - 1):
		op(i + 1, i + 2)
else:
	base = mn
	bi = A.index(base) + 1
	op(bi, N)
	for i in range(N, 1, -1):
		op(i, i - 1)


n = int(input())
a = list(map(int, input().split()))
count = 0
ans = []
mi = min(a)
ma = max(a)
plus = True
if ma >= 0 and mi <= 0:
	if abs(mi) < ma:
		plus = True
		idx = a.index(ma) + 1
	else:
		plus = False
		idx = a.index(mi) + 1
	for i in range(1, n + 1):
		if i == idx:
			continue
		ans.append([idx, i])
	count += n - 1
else:
	plus = ma > 0
if plus:
	for i in range(1, n):
		ans.append([i, i + 1])
else:
	for i in range(n - 1):
		ans.append([n - i, n - i - 1])
print(count + n - 1)
for a in ans:
	print('{} {}'.format(a[0], a[1]))


n = int(input())
a = list(map(int, input().split()))
s = min(a)
b = max(a)
si = a.index(s)
bi = a.index(b)
op = []
if s + b >= 0:
	for i in range(n):
		if a[i] < 0:
			op.append((bi + 1, i + 1))
	for i in range(n - 1):
		op.append((i + 1, i + 2))
else:
	for i in range(n):
		if a[i] > 0:
			op.append((si + 1, i + 1))
	for i in reversed(range(n - 1)):
		op.append((i + 2, i + 1))
print(len(op))
for (x, y) in op:
	print(x, y)


N = int(input())
A = list(map(int, input().split()))
Min = min(A)
Max = max(A)
if Min >= 0:
	cnt = N - 1
	ans = []
	for i in range(1, N):
		ans.append((i, i + 1))
elif Max <= 0:
	cnt = N - 1
	ans = []
	for i in range(N - 1, 0, -1):
		ans.append((i + 1, i))
elif abs(Min) >= abs(Max):
	idx = A.index(Min)
	ans = []
	cnt = 2 * N - 1
	for i in range(N):
		ans.append((idx + 1, i + 1))
	for i in range(N - 1, 0, -1):
		ans.append((i + 1, i))
elif abs(Min) < abs(Max):
	idx = A.index(Max)
	ans = []
	cnt = 2 * N - 1
	for i in range(N):
		ans.append((idx + 1, i + 1))
	for i in range(1, N):
		ans.append((i, i + 1))
print(cnt)
for i in range(cnt):
	print(str(ans[i][0]) + ' ' + str(ans[i][1]))


n = int(input())
a = list(map(int, input().split()))
s = max(a)
t = min(a)
if s == t:
	print(0)
elif abs(s) > abs(t):
	ss = a.index(s)
	print(2 * n - 2)
	for i in range(0, n):
		if i != ss:
			print(str(ss + 1) + ' ' + str(i + 1))
	for i in range(1, n):
		print(str(i) + ' ' + str(i + 1))
else:
	tt = a.index(t)
	print(2 * n - 2)
	for i in range(n):
		if i != tt:
			print(str(tt + 1) + ' ' + str(i + 1))
	for i in range(1, n):
		print(str(n - i + 1) + ' ' + str(n - i))


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


from itertools import chain, product
N = int(input())
a = list(map(int, input().split()))
a_abs_max = 0
for i in range(N):
	if a_abs_max < abs(a[i]):
		a_abs_max = abs(a[i])
		a_abs_max_index = i
result = []
if a_abs_max > 0:
	if a[a_abs_max_index] > 0:
		result = list(chain(iter([(a_abs_max_index + 1, a_abs_max_index + 1)]), product([a_abs_max_index + 1], range(1, N + 1)), map(lambda i: (i + 1, i + 2), range(N - 1))))
	elif a[a_abs_max_index] < 0:
		result = list(chain(iter([(a_abs_max_index + 1, a_abs_max_index + 1)]), product([a_abs_max_index + 1], range(1, N + 1)), map(lambda i: (i + 1, i), range(N - 1, 0, -1))))
print(len(result))
for (x, y) in result:
	print(x, y)


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

def solve2():
	for i in reversed(range(1, N)):
		ans.append((i + 1, i))
		A[i - 1] += A[i]
N = int(input())
A = list(map(int, input().split()))
l = min(A)
r = max(A)
wl = A.index(l)
wr = A.index(r)
ans = []
if l >= 0:
	solve1()
elif r < 0:
	solve2()
elif abs(l) > abs(r):
	for i in range(N):
		if A[i] > 0:
			ans.append((wl + 1, i + 1))
			A[i] += l
	solve2()
else:
	for i in range(N):
		if A[i] < 0:
			ans.append((wr + 1, i + 1))
			A[i] += r
	solve1()
print(len(ans))
for (x, y) in ans:
	print(x, y)


n = int(input())
a = [int(x) for x in input().split()]
mi = 10 ** 7
ma = -10 ** 7
mi_idx = 0
ma_idx = 0
for (i, v) in enumerate(a):
	if v < mi:
		mi = v
		mi_idx = i
	if v > ma:
		ma = v
		ma_idx = i
print(2 * n - 1)
if abs(ma) >= abs(mi):
	for i in range(1, len(a) + 1):
		print(ma_idx + 1, i)
	for i in range(1, len(a)):
		print(i, i + 1)
else:
	for i in range(1, len(a) + 1):
		print(mi_idx + 1, i)
	for i in range(len(a), 1, -1):
		print(i, i - 1)


n = int(input())
a = list(map(int, input().split()))
j = -1
m = -1
for i in range(n):
	t = abs(a[i])
	if t > m:
		j = i
		m = t
print(2 * (n - 1))
for i in range(n):
	if i == j:
		continue
	print(str(j + 1) + ' ' + str(i + 1))
if a[j] > 0:
	for i in range(n - 1):
		print(str(i + 1) + ' ' + str(i + 1 + 1))
else:
	for i in range(n - 1):
		print(str(n - 1 - i + 1) + ' ' + str(n - 1 - (i + 1) + 1))


N = int(input())
a = list(map(int, input().split()))
m = 10 ** 6 + 1
M = -10 ** 6 - 1
j = -1
k = -1
for i in range(N):
	if M < a[i]:
		M = a[i]
		j = i
	if m > a[i]:
		m = a[i]
		k = i
print(2 * N - 2)
if -m < M:
	for i in range(N):
		if i != j:
			print('{} {}'.format(j + 1, i + 1))
	for i in range(N - 1):
		print('{} {}'.format(i + 1, i + 2))
else:
	for i in range(N):
		if i != k:
			print('{} {}'.format(k + 1, i + 1))
	for i in range(N - 1, 0, -1):
		print('{} {}'.format(i + 1, i))


N = int(input())
seq = list(map(int, input().split()))
(M, m) = (max(seq), min(seq))
for i in range(N):
	if seq[i] == M:
		x = i
	if seq[i] == m:
		y = i
print(2 * N - 1)
if M + m >= 0:
	for i in range(N):
		print(x + 1, i + 1)
	for i in range(N - 1):
		print(i + 1, i + 2)
else:
	for i in range(N):
		print(y + 1, i + 1)
	for i in range(N - 1, 0, -1):
		print(i + 1, i)


N = int(input())
a = list(map(int, input().split()))
maxa = max(a)
mina = min(a)
add = None
if abs(maxa) > abs(mina):
	add = maxa
else:
	add = mina
index = a.index(add)
ans = [(index, i) for i in range(N) if i != index]
if add > 0:
	ans += [(i, i + 1) for i in range(N - 1)]
else:
	ans += [(i, i - 1) for i in range(N - 1, 0, -1)]
ans = list(map(lambda x: (x[0] + 1, x[1] + 1), ans))
print(len(ans))
print('\n'.join(map(lambda x: '%d %d' % x, ans)))


N = int(input())
A = list(map(int, input().split()))
Amax = max(A)
Amin = min(A)
outlis = []
if Amin > 0:
	print(N - 1)
	for i in range(N - 1):
		print(i + 1, i + 2)
elif Amax < 0:
	print(N - 1)
	for i in range(N - 1):
		print(N - i, N - i - 1)
else:
	print(2 * N - 2)
	if abs(Amax) > abs(Amin):
		maxi = A.index(Amax) + 1
		for i in range(N):
			if i == maxi - 1:
				pass
			else:
				print(maxi, i + 1)
		for i in range(N - 1):
			print(i + 1, i + 2)
	else:
		mini = A.index(Amin) + 1
		for i in range(N):
			if i == mini - 1:
				pass
			else:
				print(mini, i + 1)
		for i in range(N - 1):
			print(N - i, N - i - 1)


N = int(input())
A = list(map(int, input().split()))
INF = 10 ** 6 + 1
(MIN, MAX) = (INF, -INF)
for (i, a) in enumerate(A, start=1):
	if a < MIN:
		(MIN, MINi) = (a, i)
	if MAX < a:
		(MAX, MAXi) = (a, i)
if MAX < 0 or MAX + MIN < 0:
	print(2 * N - 1)
	for i in range(1, N + 1):
		print(MINi, i)
	for i in range(2, N + 1)[::-1]:
		print(i, i - 1)
	quit()
flag = 0
if MIN < 0 and MAX + MIN >= 0:
	print(2 * N - 1)
	flag = 1
	for i in range(N):
		print(MAXi, i + 1)
if not flag:
	print(N - 1)
for i in range(1, N):
	print(i, i + 1)


n = int(input())
a = list(map(int, input().split()))
min1 = min(a)
max1 = max(a)
idx1 = a.index(min1)
idx2 = a.index(max1)
print(2 * n - 2)
if abs(min1) < abs(max1):
	for i in range(n):
		if i != idx2:
			print(idx2 + 1, i + 1)
	for i in range(n - 1):
		print(i + 1, i + 2)
else:
	for i in range(n):
		if i != idx1:
			print(idx1 + 1, i + 1)
	for i in range(n - 1):
		print(n - i, n - i - 1)


N = int(input())
A = tuple(map(int, input().split()))
(M, m) = (max(A), min(A))
print(2 * N - 2)
if abs(M) >= abs(m):
	ind = A.index(M)
	for x in set(range(N)) - {ind}:
		print(ind + 1, x + 1)
	for x in range(1, N):
		print(x, x + 1)
else:
	ind = A.index(m)
	for x in set(range(N)) - {ind}:
		print(ind + 1, x + 1)
	for x in range(N - 1, 0, -1):
		print(x + 1, x)


N = int(input())
A = [int(x) for x in input().split()]
max_A = max(A)
min_A = min(A)
if min_A == max_A == 0:
	print(0)
elif 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)[::-1]:
		print(i + 2, i + 1)
else:
	print(2 * N - 1)
	if abs(max_A) >= abs(min_A):
		index = A.index(max_A)
		for i in range(N):
			print(index + 1, i + 1)
		for i in range(N - 1):
			print(i + 1, i + 2)
	else:
		index = A.index(min_A)
		for i in range(N):
			print(index + 1, i + 1)
		for i in range(N - 1)[::-1]:
			print(i + 2, i + 1)


n = int(input())
a = list(map(int, input().split()))
amax = max(a)
amin = min(a)
print(2 * n - 1)
if amax > abs(amin):
	a_i = a.index(amax)
else:
	amax += amin
	a_i = a.index(amin)
for i in range(n):
	print(a_i + 1, i + 1)
if amax > 0:
	for i in range(n - 1):
		print(i + 1, i + 2)
else:
	for i in range(n, 1, -1):
		print(i, i - 1)


N = int(input())
A = list(map(int, input().split()))
amax = -10 ** 7
amin = 10 ** 7
indexmax = 51
indexmin = 51
print(2 * N - 1)
for i in range(N):
	if amax < A[i]:
		amax = A[i]
		indexmax = i
	if amin > A[i]:
		amin = A[i]
		indexmin = i
if abs(amax) >= abs(amin):
	for i in range(N):
		print(indexmax + 1, end=' ')
		print(i + 1)
	for i in range(N - 1):
		print(i + 1, end=' ')
		print(i + 2)
else:
	for i in range(N):
		print(indexmin + 1, end=' ')
		print(i + 1)
	for i in range(N - 1):
		print(N - i, end=' ')
		print(N - i - 1)


n = int(input())
a = list(map(int, input().split()))
b = 0
by = 0
flg = 0
for (i, j) in enumerate(a):
	if abs(j) > abs(b):
		b = j
		by = i + 1
		if j > 0:
			flg = 1
		else:
			flg = 0
ans = []
if flg == 1:
	x = min(a)
	if x < 0:
		for i in range(n):
			if a[i] != b:
				a[i] += b
				ans.append([by, i + 1])
	for i in range(1, n):
		a[i] += a[i - 1]
		ans.append([i, i + 1])
else:
	x = max(a)
	if x > 0:
		for i in range(n - 1, -1, -1):
			if a[i] != b:
				a[i] += b
				ans.append([by, 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()))
maxim = max(A)
mini = min(A)
if maxim == mini:
	print(0)
	exit()
if abs(maxim) >= abs(mini):
	max_idx = A.index(maxim) + 1
	print(2 * n)
	print(max_idx, 1)
	print(max_idx, 1)
	for i in range(1, n):
		print(i, i + 1)
		print(i, i + 1)
else:
	min_idx = A.index(mini) + 1
	print(2 * n)
	print(min_idx, n)
	print(min_idx, 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()))
MAX = max(A)
MIN = min(A)
print(2 * N - 1)
if MAX >= -1 * MIN:
	j = A.index(MAX)
	for i in range(N):
		print(*[j + 1, i + 1])
	for i in range(N - 1):
		print(*[i + 1, i + 2])
else:
	j = A.index(MIN)
	for i in range(N):
		print(*[j + 1, i + 1])
	for i in range(N - 1, 0, -1):
		print(*[i + 1, i])


N = int(input())
A = list(map(int, input().split()))
A_abs = []
for a in A:
	A_abs.append(abs(a))
ans = []
m = max(A_abs)
midx = A_abs.index(m)
print(2 * N - 2)
for i in range(N):
	if not i == midx:
		print(str(midx + 1) + ' ' + str(i + 1))
for i in range(N - 1):
	if A[midx] >= 0:
		print(str(i + 1) + ' ' + str(i + 2))
	else:
		print(str(N - i) + ' ' + str(N - i - 1))


n = int(input())
aa = list(map(int, input().split()))
mx_v = 0
mn_v = 0
for i in range(n):
	if aa[i] > mx_v:
		mx_v = aa[i]
		mx_i = i + 1
	if aa[i] < mn_v:
		mn_v = aa[i]
		mn_i = i + 1
ans = []
if abs(mx_v) >= abs(mn_v) and mx_v != 0:
	for i in range(n):
		if aa[i] < 0:
			ans.append((mx_i, i + 1))
	for i in range(1, n):
		ans.append((i, i + 1))
if abs(mx_v) < abs(mn_v):
	for i in range(n):
		if aa[i] > 0:
			ans.append((mn_i, i + 1))
	for i in range(n, 1, -1):
		ans.append((i, i - 1))
print(len(ans))
for (x, y) in ans:
	print(x, y)


N = int(input())
A = list(map(int, input().split()))
Ans = []
(maxA, minA, maxAi, minAi) = (A[0], A[0], 0, 0)
for i in range(1, N):
	if A[i] > maxA:
		maxA = A[i]
		maxAi = i
	if A[i] < minA:
		minA = A[i]
		minAi = i
if abs(maxA) >= abs(minA):
	for i in range(N):
		if i != maxAi:
			Ans.append((maxAi, i))
	for i in range(N - 1):
		Ans.append((i, i + 1))
else:
	for i in range(N):
		if i != minAi:
			Ans.append((minAi, i))
	for i in range(N - 1):
		Ans.append((N - 1 - i, N - 1 - i - 1))
print(len(Ans))
for (x, y) in Ans:
	print(x + 1, y + 1)


N = int(input())
A_arr = [int(x) for x in input().split()]
A_max = max(A_arr)
A_min = min(A_arr)
ans_arr = []
if A_max > -A_min:
	Am = A_arr.index(A_max)
	for i in range(len(A_arr)):
		if i == Am:
			continue
		ans_arr.append((Am + 1, i + 1))
	for i in range(len(A_arr) - 1):
		ans_arr.append((i + 1, i + 2))
else:
	Am = A_arr.index(A_min)
	for i in range(len(A_arr)):
		if i == Am:
			continue
		ans_arr.append((Am + 1, i + 1))
	for i in range(len(A_arr) - 1, 0, -1):
		ans_arr.append((i + 1, i))
print(len(ans_arr))
for (i, j) in ans_arr:
	print(i, j)


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


n = int(input())
a = list(map(int, input().split()))
ans = []
a_min = 10 ** 6 + 1
a_max = -(10 ** 6 + 1)
for i in range(n):
	if a[i] > a_max:
		a_max = a[i]
		i_max = i
	if a[i] < a_min:
		a_min = a[i]
		i_min = i
if a_max > abs(a_min):
	for i in range(n):
		if a[i] < 0:
			a[i] += a_max
			ans.append(str(i_max + 1) + ' ' + str(i + 1))
	for i in range(1, n):
		a[i] += a[i - 1]
		ans.append(str(i) + ' ' + str(i + 1))
else:
	for i in range(n):
		if a[i] > 0:
			a[i] -= a_min
			ans.append(str(i_min + 1) + ' ' + str(i + 1))
	for i in range(n - 2, -1, -1):
		a[i] += a[i + 1]
		ans.append(str(i + 2) + ' ' + str(i + 1))
print(len(ans))
for i in range(len(ans)):
	print(ans[i])


n = int(input())
A = [int(i) for i in input().split()]
C = []
max_A = max(A)
max_idx = A.index(max_A)
min_A = min(A)
min_idx = A.index(min_A)
if abs(max_A) >= abs(min_A):
	for i in range(n):
		A[i] += max_A
		C.append([max_idx + 1, i + 1])
	for i in range(1, n):
		A[i] += A[i - 1]
		C.append([i, i + 1])
else:
	for i in range(n):
		A[i] += min_A
		C.append([min_idx + 1, i + 1])
	for i in range(n, 1, -1):
		A[i - 2] += A[i - 1]
		C.append([i, i - 1])
print(len(C))
for (i, j) in C:
	print('{0} {1}'.format(i, j))


N = int(input())
a = list(map(int, input().split()))
lis = []
mi = float('inf')
ma = float('-inf')
mi_ind = 0
ma_ind = 0
for i in range(N):
	if mi > a[i]:
		mi = a[i]
		mi_ind = i
	if ma < a[i]:
		ma = a[i]
		ma_ind = i
flag = None
if mi < 0 and 0 < ma:
	if abs(mi) <= abs(ma):
		flag = 0
		for i in range(N):
			if a[i] < 0:
				lis.append([ma_ind + 1, i + 1])
	else:
		flag = 1
		for i in range(N):
			if a[i] > 0:
				lis.append([mi_ind + 1, i + 1])
if mi >= 0 or flag == 0:
	for i in range(N - 1):
		lis.append([i + 1, i + 2])
else:
	for i in range(N - 1):
		lis.append([N - i, N - 1 - i])
print(len(lis))
for i in lis:
	print(i[0], i[1])


n = int(input())
a = [int(i) for i in input().split()]
(k, m) = (0, abs(a[0]))
for i in range(1, n):
	if abs(a[i]) > m:
		m = abs(a[i])
		k = i
print(2 * n - 1)
for i in range(n):
	print(k + 1, i + 1)
if a[k] >= 0:
	for i in range(1, n):
		print(i, i + 1)
else:
	for i in range(1, n):
		print(n + 1 - i, n + 1 - i - 1)


n = int(input())
a = list(map(int, input().split()))
(c, d) = (min(a), max(a))
ans = []
if abs(c) > abs(d):
	c_ = a.index(c)
	for i in range(n):
		if i != c_ and a[i] > 0:
			ans.append(str(c_ + 1) + ' ' + str(i + 1))
	for i in range(n - 1, 0, -1):
		ans.append(str(i + 1) + ' ' + str(i))
else:
	d_ = a.index(d)
	for i in range(n):
		if i != d_ and a[i] < 0:
			ans.append(str(d_ + 1) + ' ' + str(i + 1))
	for i in range(n - 1):
		ans.append(str(i + 1) + ' ' + str(i + 2))
l = len(ans)
print(l)
for i in range(l):
	print(ans[i])


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


N = int(input())
alist = [int(x) for x in input().split()]
positive = max(alist) + min(alist) >= 0
if positive:
	argmaxabs = alist.index(max(alist))
else:
	argmaxabs = alist.index(min(alist))
print(2 * N - 2)
for i in range(1, N + 1):
	if not argmaxabs + 1 == i:
		print(str(argmaxabs + 1) + ' ' + str(i))
if positive:
	for i in range(1, N):
		print(str(i) + ' ' + str(i + 1))
else:
	for i in range(N, 1, -1):
		print(str(i) + ' ' + str(i - 1))


n = int(input())
A = list(map(int, input().split()))
M = max(A)
m = min(A)
for (i, a) in enumerate(A):
	if a == M:
		max_id = i
	if a == m:
		min_id = i
ans = []
if m >= 0:
	for i in range(n - 1):
		ans.append((i + 1, i + 2))
elif M <= 0:
	for i in reversed(range(1, n)):
		ans.append((i + 1, i))
elif abs(M) >= abs(m):
	for (i, a) in enumerate(A):
		if a < 0:
			ans.append((max_id + 1, i + 1))
	for i in range(n - 1):
		ans.append((i + 1, i + 2))
else:
	for (i, a) in enumerate(A):
		if a > 0:
			ans.append((min_id + 1, i + 1))
	for i in reversed(range(1, n)):
		ans.append((i + 1, i))
print(len(ans))
for i in range(len(ans)):
	print(*ans[i])


n = int(input())
l = list(map(int, input().split()))
ma = max(l)
mi = min(l)
ans = []
if abs(ma) >= abs(mi):
	ind = l.index(ma)
	if ind != 0:
		ans.append([ind + 1, 1])
		ans.append([ind + 1, 1])
	for i in range(1, n):
		ans.append([i, i + 1])
		ans.append([i, i + 1])
else:
	ind = l.index(mi)
	if ind != n - 1:
		ans.append([ind + 1, n])
		ans.append([ind + 1, n])
	for i in range(n - 2, -1, -1):
		ans.append([i + 2, 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()))
mn = min(a)
mx = max(a)
bb = mx if abs(mx) >= abs(mn) else mn
base = a.index(bb)
print(n + n - 1)
[print(base + 1, i + 1) for i in range(n)]
if abs(mx) >= abs(mn):
	[print(i, i + 1) for i in range(1, n)]
else:
	[print(i + 1, i) for i in range(1, n)[::-1]]


N = int(input())
a = list(map(int, input().split()))
maxa = max(a)
mina = min(a)
print(2 * N - 1)
r = False
if abs(maxa) >= abs(mina):
	d = maxa
else:
	r = True
	d = mina
ind = a.index(d) + 1
for i in range(N):
	print(ind, i + 1)
if r:
	for i in range(N - 1)[::-1]:
		print(i + 2, i + 1)
else:
	for i in range(N - 1):
		print(i + 1, i + 2)


N = int(input())
A = list(map(int, input().split()))
out = []
cnt = 0
Amax = max(A)
Amaxi = A.index(Amax)
Amin = min(A)
Amini = A.index(Amin)
if abs(Amax) >= abs(Amin):
	for i in range(N):
		if i == Amaxi:
			continue
		else:
			A[i] = A[i] + Amax
			out.append([Amaxi + 1, i + 1])
			cnt += 1
	for i in range(1, N):
		A[i] = A[i - 1] + A[i]
		out.append([i, i + 1])
		cnt += 1
else:
	for i in range(N):
		if i == Amini:
			continue
		else:
			A[i] = A[i] + Amin
			out.append([Amini + 1, i + 1])
			cnt += 1
	for i in range(1, N):
		A[N - i - 1] = A[N - i] + A[N - i - 1]
		out.append([N - i + 1, N - i])
		cnt += 1
print(cnt)
for i in range(len(out)):
	X = out[i]
	print(*X)


import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
A = 0
amax = 0
imax = 1
for i in range(N):
	if A < abs(a[i]):
		A = abs(a[i])
		amax = a[i]
		imax = i + 1
ans = []
for i in range(N):
	ans.append([imax, i + 1])
if amax >= 0:
	for i in range(1, N):
		ans.append([i, i + 1])
else:
	for i in range(1, N):
		ans.append([N - i + 1, N - i])
print(len(ans))
for i in ans:
	print(*i)


import sys
readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
	n = int(readline())
	a = list(map(int, readline().split()))
	b = list(map(abs, a))
	idx = b.index(max(b))
	res = []
	for (i, x) in enumerate(a):
		a[i] += a[idx]
		res.append((idx + 1, i + 1))
	if a[idx] > 0:
		for i in range(1, n):
			if a[i - 1] > a[i]:
				a[i] += a[i - 1]
				res.append((i, i + 1))
	elif a[idx] < 0:
		for i in range(n - 2, -1, -1):
			if a[i] > a[i + 1]:
				a[i] += a[i + 1]
				res.append((i + 2, i + 1))
	print(len(res))
	for (x, y) in res:
		print(x, y)
main()


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


import sys
read = sys.stdin.readline
ra = range
enu = enumerate

def read_ints():
	return list(map(int, read().split()))

def read_a_int():
	return int(read())
N = read_a_int()
A = read_ints()
(ma, mi) = (max(A), min(A))
print(2 * N - 2)
if abs(ma) > abs(mi):
	x = A.index(ma)
	for y in range(N):
		if x == y:
			continue
		print(x + 1, y + 1)
	for i in range(1, N):
		print(i, i + 1)
else:
	x = A.index(mi)
	for y in range(N):
		if x == y:
			continue
		print(x + 1, y + 1)
	for i in range(N, 1, -1):
		print(i, i - 1)


n = int(input())
a = [int(i) for i in input().split()]
ans = []
positive_flag = True
if 0 <= min(a):
	positive_flag = True
elif max(a) <= 0:
	positive_flag = False
elif min(a) * -1 <= max(a):
	positive_flag = True
	maxId = a.index(max(a))
	for i in range(n):
		if i != maxId:
			ans.append([maxId + 1, i + 1])
else:
	positive_flag = False
	minId = a.index(min(a))
	for i in range(n):
		if i != minId:
			ans.append([minId + 1, i + 1])
if positive_flag:
	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 num in ans:
	print(str(num[0]) + ' ' + str(num[1]))


n = int(input())
a = [int(i) for i in input().split()]
M = max(a)
m = min(a)
print(2 * n - 1)
if abs(M) > abs(m):
	Mi = a.index(M)
	for i in range(n):
		print(Mi + 1, i + 1)
	for i in range(n - 1):
		print(i + 1, i + 2)
else:
	mi = a.index(m)
	for i in range(n):
		print(mi + 1, i + 1)
	for i in range(n - 1)[::-1]:
		print(i + 2, i + 1)


N = int(input())
a = list(map(int, input().split()))
mx = max(a)
mn = min(a)
proc = []
if mx >= -1 * mn:
	i = a.index(mx)
	for j in range(len(a)):
		if a[j] < 0:
			proc.append([i + 1, j + 1])
			a[j] += a[i]
	for j in range(len(a) - 1):
		if a[j] > a[j + 1]:
			proc.append([j + 1, j + 2])
			a[j + 1] += a[j]
else:
	i = a.index(mn)
	for j in range(len(a)):
		if a[j] > 0:
			proc.append([i + 1, j + 1])
			a[j] += a[i]
	for j in reversed(range(len(a) - 1)):
		if a[j] > a[j + 1]:
			proc.append([j + 2, j + 1])
			a[j] += a[j + 1]
print(len(proc))
for k in proc:
	print(k[0], k[1])


I = int(input())
L = list(map(int, input().split()))
print(2 * I - 1, flush=True)
m = 0
m_index = 0
for (i, item) in enumerate(L):
	if abs(item) > abs(m):
		m = item
		m_index = i
for i in range(I):
	print(m_index + 1, i + 1, flush=True)
if m >= 0:
	for i in range(0, I - 1):
		print(i + 1, i + 2)
else:
	for i in range(I, 1, -1):
		print(i, i - 1)


n = int(input())
a = [int(i) for i in input().split()]
(num, num2) = (0, 0)
for i in range(n):
	if abs(a[i]) > abs(num):
		(num, num2) = (a[i], i)
print(2 * n - 2)
for i in range(n):
	if i != num2:
		print(num2 + 1, i + 1)
if num < 0:
	for i in range(n - 1, 0, -1):
		print(i + 1, i)
else:
	for i in range(n - 1):
		print(i + 1, i + 2)


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


n = int(input())
a = input().split()
a = [int(m) for m in a]
li = []
cnt = 0
if abs(min(a)) <= abs(max(a)):
	for i in range(1, n):
		while True:
			if a[i - 1] <= a[i]:
				break
			else:
				li.append([a.index(max(a)) + 1, i + 1])
				a[i] += max(a)
				cnt += 1
else:
	for i in range(1, n):
		while True:
			if a[-i] >= a[-i - 1]:
				break
			else:
				li.append([a.index(min(a)) + 1, n - i])
				a[-i - 1] += min(a)
				cnt += 1
print(cnt)
for i in range(cnt):
	print(li[i][0], li[i][1])


n = int(input())
a = list(map(int, input().split()))
M = a.index(max(a))
m = a.index(min(a))
if max(a) >= -min(a):
	r = max(a)
	for i in range(n):
		a[i] += r
	print(n * 2 - 2)
	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:
	print(n * 2 - 2)
	r = min(a)
	for i in range(n):
		a[i] += r
	for i in range(n):
		if i != m:
			print(m + 1, i + 1)
	for i in range(n - 1):
		print(n - i, n - i - 1)


n = int(input())
A = list(map(int, input().split()))
ans = []
maxa = max(A)
mina = min(A)
if abs(mina) > abs(maxa):
	for i in range(n)[:0:-1]:
		if A[i - 1] > A[i]:
			while A[i - 1] > A[i]:
				ma = min(A)
				argmina = A.index(ma)
				A[i - 1] += ma
				ans.append((argmina + 1, i - 1 + 1))
else:
	for i in range(n - 1):
		pa = A[i]
		aa = A[i + 1]
		if pa > aa:
			while pa > A[i + 1]:
				ma = max(A)
				argmaxa = A.index(ma)
				A[i + 1] += ma
				ans.append((argmaxa + 1, i + 1 + 1))
print(len(ans))
for a in ans:
	print(*a)


n = int(input())
al = list(map(int, input().split()))
pos = ''
max_abs = 0
value = ''
for (idx, a) in enumerate(al):
	if abs(a) >= max_abs:
		pos = idx + 1
		max_abs = abs(a)
		value = a
print(2 * n - 2)
if value >= 0:
	print(pos)
	print(2)
	print(pos)
	print(2)
	for i in range(2, n):
		print(i)
		print(i + 1)
		print(i)
		print(i + 1)
else:
	print(pos)
	print(n - 1)
	print(pos)
	print(n - 1)
	for i in range(n - 1, 1, -1):
		print(i)
		print(i - 1)
		print(i)
		print(i - 1)


def getN():
	return int(input())

def getMN():
	a = input().split()
	b = [int(i) for i in a]
	return (b[0], b[1])

def getlist():
	a = input().split()
	b = [int(i) for i in a]
	return b
n = getN()
nums = getlist()
ln = len(nums)
(maxn, minn) = (max(nums), min(nums))
already = False
if minn >= 0:
	plus = True
if maxn < 0:
	plus = False
if maxn >= 0 and minn < 0:
	print(ln * 2 - 1)
	already = True
	if abs(maxn) > abs(minn):
		source = nums.index(maxn)
		plus = True
	else:
		source = nums.index(minn)
		plus = False
	for i in range(len(nums)):
		print(source + 1, i + 1)
if not already:
	print(ln - 1)
if plus:
	for i in range(ln - 1):
		print(i + 1, i + 2)
else:
	for i in range(ln - 1):
		print(ln - i, ln - i - 1)


import copy
N = int(input())
a = [int(i) for i in input().split()]
B = copy.deepcopy(a)
A = 0
for i in range(N):
	if a[i] < 0:
		a[i] *= -1
	else:
		continue
q = 0
absmax = max(a)
print(2 * N - 1)
for i in range(N):
	if max(a) == a[i]:
		q = i
		break
if B[q] >= 0:
	for i in range(N):
		B[i] += absmax
		print('{} {}'.format(q + 1, i + 1))
	for j in range(1, N):
		print('{} {}'.format(j, j + 1))
else:
	for i in range(N):
		B[i] -= absmax
		print('{} {}'.format(q + 1, i + 1))
	for j in range(1, N):
		print('{} {}'.format(N - j + 1, N - j))


n = int(input())
a = list(map(int, input().split()))
ma = max(a)
mi = min(a)
num = 0
ans = []
if ma >= -mi:
	ind = a.index(ma)
	for i in range(1, n):
		while a[i - 1] > a[i]:
			num += 1
			ans.append(str(ind + 1) + ' ' + str(i + 1))
			a[i] += ma
			if a[i] > ma:
				ma = a[i]
				ind = i
else:
	ind = a.index(mi)
	for i in range(n - 2, -1, -1):
		while a[i] > a[i + 1]:
			num += 1
			ans.append(str(ind + 1) + ' ' + str(i + 1))
			a[i] += mi
			if a[i] < mi:
				mi = a[i]
				ind = i
print(num)
for i in ans:
	print(i)


N = int(input())
A = list(map(int, input().split()))
maxi = max(((abs(a), i) for (i, a) in enumerate(A)))[1]
if A[maxi] == 0:
	print(0)
	exit()
print(2 * (N - 1))
for i in range(N):
	if i == maxi:
		continue
	print(maxi + 1, i + 1)
if A[maxi] > 0:
	for i in range(N - 1):
		print(i + 1, i + 2)
else:
	for i in range(N - 1)[::-1]:
		print(i + 2, i + 1)


n = int(input())
a = [int(item) for item in input().split()]
mina = min(a)
min_index = a.index(mina)
maxa = max(a)
max_index = a.index(maxa)
if abs(maxa) > abs(mina):
	sign = maxa
	sign_id = max_index
else:
	sign = mina
	sign_id = min_index
print(n + n - 1)
if sign >= 0:
	for i in range(n):
		a[i] += sign
		print(sign_id + 1, i + 1)
	for i in range(n - 1):
		a[i + 1] += a[i]
		print(i + 1, i + 2)
else:
	for i in range(n):
		a[i] += sign
		print(sign_id + 1, i + 1)
	for i in range(n - 1):
		a[n - i - 2] += a[n - i - 1]
		print(n - i, n - i - 1)


N = int(input())
A = list(map(int, input().split()))
A_min = min(A)
A_max = max(A)
ans = []
if abs(A_max) >= abs(A_min):
	A_max_idx = A.index(A_max)
	for i in range(1, N + 1):
		ans.append([A_max_idx + 1, i])
	for i in range(1, N):
		ans.append([i, i + 1])
else:
	A_min_idx = A.index(A_min)
	for i in range(1, N + 1):
		ans.append([A_min_idx + 1, i])
	for i in reversed(range(2, N + 1)):
		ans.append([i, i - 1])
print(len(ans))
for x in ans:
	print(*x)


N = int(input())
A = list(map(int, input().split()))
k = 0
for i in range(N):
	if abs(A[i]) > abs(A[k]):
		k = i
ans = []
if A[k] > 0:
	for i in range(N):
		if i != k:
			A[i] += A[k]
			ans.append((k + 1, i + 1))
	for i in range(N - 1):
		A[i + 1] += A[i]
		ans.append((i + 1, i + 2))
else:
	for i in range(N):
		if i != k:
			A[i] += A[k]
			ans.append((k + 1, i + 1))
	for i in range(N - 1)[::-1]:
		A[i] += A[i + 1]
		ans.append((i + 2, i + 1))
print(len(ans))
for (x, y) in ans:
	print(str(x) + ' ' + str(y))


N = int(input())
a = list(map(int, input().split()))
MAX = max(a)
MIN = min(a)
if MIN < 0:
	print(2 * N - 1)
	if abs(MAX) >= abs(MIN):
		idx = a.index(MAX) + 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) + 1
		for i in range(1, N + 1):
			print(idx, i)
		for i in range(N, 1, -1):
			print(i, i - 1)
else:
	print(N - 1)
	for i in range(1, N):
		print(i, i + 1)


def main():
	N = int(input())
	A = list(map(int, input().split()))
	C = []
	if max(A) + min(A) >= 0:
		x = A.index(max(A))
		for i in range(N):
			C.append((x + 1, i + 1))
		for i in range(1, N):
			C.append((i, i + 1))
	else:
		x = A.index(min(A))
		for i in range(N):
			C.append((x + 1, i + 1))
		for i in range(N, 1, -1):
			C.append((i, i - 1))
	print(len(C))
	for (x, y) in C:
		print(x, y)
main()


n = int(input())
a = list(map(int, input().split()))
inf = float('inf')
M = max(a)
m = min(a)
data = []
if abs(m) > abs(M):
	b = a.index(m)
	for i in range(n):
		data.append(str(b + 1) + ' ' + str(i + 1))
	for i in range(n - 1):
		data.append(str(n - i) + ' ' + str(n - i - 1))
else:
	b = a.index(M)
	for i in range(n):
		data.append(str(b + 1) + ' ' + str(i + 1))
	for i in range(1, n):
		data.append(str(i) + ' ' + str(i + 1))
print(len(data))
for u in data:
	print(u)


N = int(input())
a = list(map(int, input().split()))
max_a = max(a)
min_a = min(a)
print(2 * N - 1)
if abs(max_a) >= abs(min_a):
	for i in range(1, N + 1):
		print(a.index(max_a) + 1, i)
	for i in range(1, N):
		print(i, i + 1)
else:
	for i in range(1, N + 1):
		print(a.index(min_a) + 1, i)
	for i in range(N, 1, -1):
		print(i, i - 1)


n = int(input())
a = list(map(int, input().split()))
ans = []
if max(a) * min(a) < 0:
	if abs(max(a)) > abs(min(a)):
		for i in range(n):
			if i != a.index(max(a)):
				ans.append([a.index(max(a)) + 1, i + 1])
				a[i] += max(a)
	else:
		for i in range(n):
			if i != a.index(min(a)):
				ans.append([a.index(min(a)) + 1, i + 1])
				a[i] += min(a)
if max(a) > 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])
print(len(ans))
for i in range(len(ans)):
	print('{} {}'.format(*ans[i]))


N = int(input())
a = [0] + list(map(int, input().split()))
inde = 0
absmax = 0
for i in range(1, N + 1, 1):
	if absmax <= abs(a[i]):
		inde = i
		absmax = abs(a[i])
ans = []
for i in range(1, N + 1, 1):
	ans.append([inde, i])
if a[inde] > 0:
	for i in range(1, N, 1):
		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][0], ans[i][1])


n = int(input())
a = list(map(int, input().split()))
mi = a[0]
mii = 1
ma = a[0]
mai = 1
for i in range(n):
	if a[i] > ma:
		ma = a[i]
		mai = i + 1
	if a[i] < mi:
		mi = a[i]
		mii = i + 1
if mi >= 0:
	print(n - 1)
	for i in range(1, n):
		print(i, i + 1)
elif ma <= 0:
	print(n - 1)
	for i in range(n, 1, -1):
		print(i, i - 1)
elif abs(ma) >= abs(mi):
	print(n * 2 - 1)
	for i in range(n):
		print(mai, i + 1)
	for i in range(1, n):
		print(i, i + 1)
else:
	print(n * 2 - 1)
	for i in range(n):
		print(mii, i + 1)
	for i in range(n, 1, -1):
		print(i, i - 1)


N = int(input())
(*A,) = map(int, input().split())
minv = min(A)
maxv = max(A)
mini = A.index(minv)
maxi = A.index(maxv)
ans = []

def op(x, y):
	A[y] += A[x]
	ans.append([x, y])
if minv < 0 and maxv > 0:
	if abs(minv) <= maxv:
		for i in range(N):
			if A[i] < 0:
				op(maxi, i)
	else:
		for i in range(N):
			if A[i] > 0:
				op(mini, i)
minv = min(A)
maxv = max(A)
mini = A.index(minv)
maxi = A.index(maxv)
if maxv <= 0:
	op(mini, N - 1)
	for i in range(N - 2, -1, -1):
		op(i + 1, i)
else:
	op(maxi, 0)
	for i in range(1, N):
		op(i - 1, i)
print(len(ans))
for (x, y) in ans:
	print(x + 1, y + 1)


def main():
	N = int(input())
	a = list(map(int, input().split()))
	amax = max(a)
	amax_arg = a.index(amax)
	amin = min(a)
	amin_arg = a.index(amin)
	output = []
	if abs(amax) >= abs(amin):
		for i in range(N):
			a[i] += amax
			output.append([amax_arg + 1, i + 1])
		for i in range(N - 1):
			a[i + 1] += a[i]
			output.append([i + 1, i + 2])
	else:
		for i in range(N):
			a[i] += amin
			output.append([amin_arg + 1, i + 1])
		for i in range(N - 1):
			a[-i - 2] += a[i - 1]
			output.append([N - i, N - i - 1])
	print(len(output))
	for i in range(len(output)):
		print(str(output[i][0]) + ' ' + str(output[i][1]))
main()


N = int(input())
a = list(map(int, input().split()))
a_max = max(a)
max_idx = a.index(a_max)
a_mix = min(a)
min_idx = a.index(a_mix)
ans = ''
if abs(a_max) >= abs(a_mix):
	ans += '{}\n'.format(2 * N - 1)
	for i in range(N):
		ans += '{} {}\n'.format(max_idx + 1, i + 1)
	for i in range(1, N):
		ans += '{} {}\n'.format(i, i + 1)
else:
	ans += '{}\n'.format(2 * N - 1)
	for i in range(N):
		ans += '{} {}\n'.format(min_idx + 1, i + 1)
	for i in range(N, 1, -1):
		ans += '{} {}\n'.format(i, i - 1)
print(ans, end='')


N = int(input())
a = list(map(int, input().split()))
MAX = max(a)
MIN = min(a)
m = 0
operation = []
if abs(MAX) >= abs(MIN):
	n = a.index(MAX)
	for i in range(N):
		a[i] += MAX
		m += 1
		operation.append([n + 1, i + 1])
	for i in range(N - 1):
		a[i + 1] += a[i]
		m += 1
		operation.append([i + 1, i + 2])
else:
	n = a.index(MIN)
	for i in range(N):
		a[i] += MIN
		m += 1
		operation.append([n + 1, i + 1])
	for i in range(N - 1, 0, -1):
		a[i - 1] += a[i]
		m += 1
		operation.append([i + 1, i])
print(m)
for i in range(m):
	print(*operation[i])


import sys
n = int(input())
INF = 10 ** 18
a_ls = [int(i) for i in sys.stdin.readline().split()]
max_ind = 1
_max = a_ls[0]
min_ind = 1
_min = a_ls[0]
for (i, a) in enumerate(a_ls, 1):
	if a > _max:
		_max = a
		max_ind = i
	if a < _min:
		_min = a
		min_ind = i
flg = abs(_max) >= abs(_min)
ls = []
if flg:
	for i in range(1, n + 1):
		if i != max_ind:
			ls.append((max_ind, i))
	for i in range(1, n):
		ls.append((i, i + 1))
else:
	for i in range(1, n + 1):
		if i != min_ind:
			ls.append((min_ind, i))
	for i in range(n, 1, -1):
		ls.append((i, i - 1))
print(len(ls))
for (x, y) in ls:
	print(x, y)


n = int(input())
a = list(map(int, input().split()))
m = 0
id = -1
for i in range(n):
	if abs(a[i]) >= abs(m):
		m = a[i]
		id = i
ope = []
for i in range(n):
	a[i] += m
	ope.append([id + 1, i + 1])
if m >= 0:
	for i in range(1, n):
		a[i] += a[i - 1]
		ope.append([i, i + 1])
else:
	for i in range(1, n):
		a[n - i - 1] += a[n - i]
		ope.append([n - i + 1, n - i])
print(len(ope))
for x in ope:
	print(x[0], x[1])


N = int(input())
A = list(map(int, input().split()))
print(2 * N - 2)
maxa = max(A)
mina = min(A)
if abs(maxa) > abs(mina):
	maxi = A.index(maxa)
	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)
	for i in range(N):
		if i == mini:
			continue
		print(mini + 1, i + 1)
	for i in range(N - 1):
		print(N - i, N - i - 1)


N = int(input())
A = list(map(int, input().split()))
(M, X, Xi) = (0, 0, 1)
for (i, a) in enumerate(A, start=1):
	if abs(a) > M:
		M = abs(a)
		X = a
		Xi = i
if X > 0:
	ans = []
	for i in range(N):
		A[i] += X
		ans.append((Xi, i + 1))
	for i in range(N - 1):
		A[i + 1] += A[i]
		ans.append((i + 1, i + 2))
	print(len(ans))
	for (x, y) in ans:
		print(x, y)
else:
	ans = []
	for i in range(N):
		A[i] += X
		ans.append((Xi, i + 1))
	for i in range(N - 1, 0, -1):
		A[i - 1] += A[i]
		ans.append((i + 1, i))
	print(len(ans))
	for (x, y) in ans:
		print(x, y)


N = int(input())
arr = [0] + list(map(int, input().split()))
max_index = 0
max_ = 0
for i in range(N + 1):
	if abs(arr[i]) >= max_:
		max_ = abs(arr[i])
		max_index = i
print(2 * N - 2)
for i in range(1, N + 1):
	if i != max_index:
		print('{0} {1}'.format(max_index, i))
if arr[max_index] > 0:
	for i in range(1, N):
		print('{0} {1}'.format(i, i + 1))
else:
	for i in range(N, 1, -1):
		print('{0} {1}'.format(i, i - 1))


import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
l = 0
for i in range(1, N):
	if abs(a[i]) > abs(a[l]):
		l = i
if a[l] == 0:
	(print(0), sys.exit())
elif a[l] > 0:
	print(N * 2)
	for i in range(2):
		print(l + 1, 1)
	for i in range(1, N):
		for j in range(2):
			print(i, i + 1)
else:
	print(N * 2)
	for i in range(2):
		print(l + 1, N)
	for i in range(N, 1, -1):
		for j in range(2):
			print(i, i - 1)


from operator import itemgetter
N = int(input())
A = list(map(int, input().split()))
i = max(enumerate(map(abs, A)), key=itemgetter(1))[0]
print(2 * N)
if A[i] < 0:
	print(i + 1, N)
	print(i + 1, N)
	for j in range(N, 1, -1):
		print(j, j - 1)
		print(j, j - 1)
else:
	print(i + 1, 1)
	print(i + 1, 1)
	for j in range(1, N):
		print(j, j + 1)
		print(j, j + 1)


n = int(input())
A = list(map(int, input().split()))
Amax = max(A)
Amin = min(A)
ans = 0
B = []
if Amin >= 0:
	ans = n - 1
	for i in range(n - 1):
		B.append([i + 1, i + 2])
elif Amax <= 0:
	ans = n - 1
	for i in range(n - 1):
		B.append([n - i, n - i - 1])
elif Amax >= -Amin:
	a = A.index(Amax)
	for i in range(n):
		if A[i] != Amax:
			ans += 1
			B.append([a + 1, i + 1])
	for i in range(n - 1):
		ans += 1
		B.append([i + 1, i + 2])
else:
	a = A.index(Amin)
	for i in range(n):
		if A[i] != Amin:
			ans += 1
			B.append([a + 1, i + 1])
	for i in range(n - 1):
		ans += 1
		B.append([n - i, n - i - 1])
print(ans)
for b in B:
	print(' '.join(map(str, b)))


n = int(input())
lis = list(map(int, input().split()))
if abs(max(lis)) >= abs(min(lis)):
	ind = lis.index(max(lis)) + 1
else:
	ind = lis.index(min(lis)) + 1
opere = []
if lis[ind - 1] > 0:
	for i in range(1, n + 1):
		opere.append([ind, i])
	for i in range(1, n):
		opere.append([i, i + 1])
else:
	for i in range(1, n + 1):
		opere.append([ind, i])
	for i in range(n - 1):
		opere.append([n - i, n - i - 1])
print(2 * n - 1)
if opere:
	for i in opere:
		print(' '.join(list(map(str, i))))


N = int(input())
A = list(map(int, input().split()))
if abs(max(A)) >= abs(min(A)):
	max_idx = A.index(max(A))
	print(2 * N - 1)
	for i in range(N):
		print(max_idx + 1, i + 1)
	for i in range(N - 1):
		print(i + 1, i + 2)
else:
	min_idx = A.index(min(A))
	print(2 * N - 1)
	for i in range(N):
		print(min_idx + 1, i + 1)
	for i in range(N, 1, -1):
		print(i, i - 1)


N = int(input())
A = list(map(int, input().split()))
mx = max(A)
mn = min(A)
ans = []
if abs(mx) > abs(mn):
	for i in range(1, N + 1):
		ans += [[A.index(mx) + 1, i]]
	for i in range(1, N):
		ans += [[i, i + 1]]
else:
	for i in range(1, N + 1):
		ans += [[A.index(mn) + 1, i]]
	for i in range(N, 1, -1):
		ans += [[i, i - 1]]
print(len(ans))
for (x, y) in ans:
	print(x, y)


N = int(input())
A = list(map(int, input().split()))
(xa, a) = max(enumerate(A), key=lambda x: abs(x[1]))
print(2 * N)
for i in range(2):
	print(xa + 1, 1 if a > 0 else N)
if a > 0:
	for i in range(1, N):
		for j in range(2):
			print(i, i + 1)
else:
	for i in range(N, 1, -1):
		for j in range(2):
			print(i, i - 1)


N = int(input())
A = list(map(int, input().split()))
MAX_ABS = 0
MAX_ABS_NUMBER = 0
MAX_ABS_NUMBER_INDEX = 1
for (i, a) in enumerate(A, start=1):
	if abs(a) > MAX_ABS:
		MAX_ABS = abs(a)
		MAX_ABS_NUMBER = a
		MAX_ABS_NUMBER_INDEX = i
if MAX_ABS_NUMBER >= 0:
	print(2 * N - 1)
	for i in range(1, N + 1):
		print(MAX_ABS_NUMBER_INDEX, i)
	for i in range(1, N):
		print(i, i + 1)
else:
	print(2 * N - 1)
	for i in range(1, N + 1):
		print(MAX_ABS_NUMBER_INDEX, i)
	for i in range(N, 1, -1):
		print(i, i - 1)


n = int(input())
a = list(map(int, input().split()))
m = 0
mi = 1
ans = [0 for i in range(n + 1)]
for (i, z) in enumerate(a, 1):
	if abs(z) > abs(m):
		m = z
		mi = i
if m >= 0:
	ans[1] = [mi, 1]
	for i in range(2, n + 1):
		ans[i] = [i - 1, i]
else:
	ans[1] = [mi, n]
	for i in range(2, n + 1):
		ans[i] = [n - i + 2, n + 1 - i]
print(2 * n)
for i in ans[1:]:
	print(i[0], i[1])
	print(i[0], i[1])


n = int(input())
a = list(map(int, input().split()))
print(2 * n - 2)
if abs(min(a)) <= abs(max(a)):
	x = a.index(max(a)) + 1
	for y in range(1, n + 1):
		if not x == y:
			print(x, y)
	for x in range(1, n):
		y = x + 1
		print(x, y)
else:
	x = a.index(min(a)) + 1
	for y in range(1, n + 1):
		if not x == y:
			print(x, y)
	for x in range(n, 1, -1):
		y = x - 1
		print(x, y)


n = int(input())
a = [int(i) for i in input().split()]
a_max = max(a)
a_min = min(a)
abs_max = a_min if abs(a_min) > abs(a_max) else a_max
abs_max_index = a.index(abs_max)
print(2 * n - 1)
total = 0
for i in range(n):
	print(abs_max_index + 1, i + 1)
	a[i] += abs_max
(my_range, next_index_diff) = (list(range(n - 1)), 1) if abs_max > 0 else (list(range(n - 1, 0, -1)), -1)
while my_range:
	index = my_range.pop(0)
	print(index + 1, index + 1 + next_index_diff)
	a[index + next_index_diff] += a[index]


def main():
	n = int(input())
	a = list(map(int, input().split()))
	absmaxindex = 0
	for i in range(1, n):
		if abs(a[i]) > abs(a[absmaxindex]):
			absmaxindex = i
	print(2 * n - 2)
	for i in range(n):
		if i == absmaxindex:
			continue
		print(absmaxindex + 1, i + 1)
	if a[absmaxindex] >= 0:
		for i in range(n - 1):
			print(i + 1, i + 2)
	else:
		for i in reversed(range(n - 1)):
			print(i + 2, i + 1)
main()


def main():
	N = int(input())
	a = list(map(int, input().split()))
	l = []
	if abs(max(a)) >= abs(min(a)):
		i = a.index(max(a))
		t = max(a)
		for j in range(1, N + 1):
			l.append((i + 1, j))
		for i in range(1, N):
			l.append((i, i + 1))
	else:
		i = a.index(min(a))
		t = min(a)
		for j in range(1, N + 1):
			l.append((i + 1, j))
		for i in range(N - 1, 0, -1):
			l.append((i + 1, i))
	print(len(l))
	for i in l:
		print(i[0], i[1])
main()


N = int(input())
a = list(map(int, input().split()))
a_max = max(a)
a_min = min(a)
if a_max >= abs(a_min):
	flag = True
	index = a.index(a_max)
else:
	flag = False
	index = a.index(a_min)
m = 2 * N - 2
print(m)
count = 0
for i in range(N):
	if i != index:
		print(index + 1, i + 1)
		count += 1
if flag:
	for i in range(N - 1):
		print(i + 1, i + 2)
		count += 1
else:
	for i in range(N - 1, 0, -1):
		print(i + 1, i)
		count += 1


import math
N = int(input())
a = list(map(int, 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 - i - 1)
elif abs(max(a)) >= abs(min(a)):
	print(2 * N - 1)
	mindex = a.index(max(a))
	for i in range(N):
		print(mindex + 1, i + 1)
	for j in range(N - 1):
		print(j + 1, j + 2)
else:
	print(2 * N - 1)
	mindex = a.index(min(a))
	for i in range(N):
		print(mindex + 1, i + 1)
	for j in range(N - 1):
		print(N - j, N - j - 1)


N = int(input())
A = list(map(int, input().split()))
(im, m) = (0, 0)
for (i, a) in enumerate(A):
	if abs(a) > abs(m):
		m = a
		im = i
operations = []
for i in range(N):
	if i == im:
		continue
	operations.append((im + 1, i + 1))
	A[i] += A[im]
if m >= 0:
	for i in range(N - 1):
		operations.append((i + 1, i + 2))
		A[i + 1] += A[i]
else:
	for i in range(N - 1, 0, -1):
		operations.append((i + 1, i))
		A[i - 1] += A[i]
print(len(operations))
for (x, y) in operations:
	print(x, y)


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


n = int(input())
ali = list(map(int, input().split()))
log = []
max_ = max(ali)
min_ = min(ali)
if abs(max_) >= abs(min_):
	max_index = ali.index(max_) + 1
	for i in range(n):
		log_i = i + 1
		log.append((max_index, log_i))
	for j in range(n - 1):
		log_j = j + 1
		mae = log_j
		ushiro = log_j + 1
		log.append((mae, ushiro))
elif abs(max_) < abs(min_):
	min_index = ali.index(min_) + 1
	for i in range(n):
		log_i = i + 1
		log.append((min_index, log_i))
	for j in range(1, n)[::-1]:
		log_j = j + 1
		mae = log_j
		ushiro = log_j - 1
		log.append((mae, ushiro))
print(len(log))
for (v1, v2) in log:
	print(str(v1) + ' ' + str(v2))


n = int(input())
a = list(map(int, input().split()))
m = 0
im = 0
for (i, ai) in enumerate(a):
	if abs(ai) >= abs(m):
		m = ai
		im = i
print(2 * n - 1)
for i in range(n):
	print(im + 1, i + 1)
if m > 0:
	for i in range(0, n - 1):
		print(i + 1, i + 2)
else:
	for i in reversed(range(1, n)):
		print(i + 1, i)


from collections import Counter
N = int(input())
a = [int(i) for i in input().split()]
schedule = []
m = 0
if -min(a) > max(a):
	mv = min(a)
	mi = a.index(mv)
	for i in range(N - 2, -1, -1):
		while a[i] > a[i + 1]:
			a[i] += mv
			schedule.append([mi + 1, i + 1])
			if a[i] < mv:
				mv = a[i]
				mi = i
			m += 1
else:
	Mv = max(a)
	Mi = a.index(Mv)
	for i in range(1, N):
		while a[i - 1] > a[i]:
			a[i] += Mv
			schedule.append([Mi + 1, i + 1])
			if a[i] > Mv:
				Mv = a[i]
				Mi = i
			m += 1
print(m)
for sch in schedule:
	print(*sch)


N = int(input())
A = list(map(int, input().split()))
K = 0
t = 0
place = 0
for i in range(N):
	if abs(A[i]) > K:
		K = abs(A[i])
		place = i
		if A[i] >= 0:
			t = 0
		else:
			t = 1
print(2 * N - 2)
if t == 0:
	print(place + 1, 2)
	print(place + 1, 2)
	for i in range(2, N):
		print(i, i + 1)
		print(i, i + 1)
else:
	print(place + 1, N - 1)
	print(place + 1, N - 1)
	for i in range(N - 2, 0, -1):
		print(i + 1, i)
		print(i + 1, i)


from sys import stdin

def main():
	readline = stdin.readline
	n = int(readline())
	a = list(map(int, readline().split()))
	max_i = 0
	for i in range(n):
		if abs(a[max_i]) < abs(a[i]):
			max_i = i
	a = list(map(lambda x: x + a[max_i], a))
	ans = []
	for i in range(n):
		ans.append([max_i + 1, i + 1])
	if a[0] >= 0:
		for i in range(n - 1):
			ans.append([i + 1, i + 2])
	else:
		for i in range(n - 1, 0, -1):
			ans.append([i + 1, i])
	print(2 * n - 1)
	for i in range(2 * n - 1):
		print(*ans[i])
main()


n = int(input())
list_a = list(map(int, input().split()))
max_a = [-1, -1]
for i in range(n):
	if abs(list_a[i]) > max_a[1]:
		max_a = [i, abs(list_a[i])]
print(2 * n - 1)
for i in range(n):
	print(max_a[0] + 1, i + 1)
if list_a[max_a[0]] > 0:
	for i in range(n - 1):
		print(i + 1, i + 2)
else:
	for i in range(n - 1)[::-1]:
		print(i + 2, i + 1)


def solve():
	N = int(input())
	a = list(map(int, input().split()))
	(max_idx, min_idx) = (-1, -1)
	(max_a, min_a) = (-10 ** 6, 10 ** 6)
	for (i, ai) in enumerate(a):
		if max_a < ai:
			max_a = ai
			max_idx = i
		if ai < min_a:
			min_a = ai
			min_idx = i
	ans = []
	if abs(min_a) <= abs(max_a):
		for i in range(N):
			ans.append([max_idx + 1, i + 1])
		for i in range(N - 1):
			ans.append([i + 1, i + 2])
	else:
		for i in range(N):
			ans.append([min_idx + 1, i + 1])
		for i in range(N, 1, -1):
			ans.append([i, i - 1])
	print(len(ans))
	for (x, y) in ans:
		print(x, y)
solve()


(N, *A) = map(int, open(0).read().split())
a = max(A, key=abs)
j = str(A.index(a) + 1)
ans = []
if a > 0:
	for (i, c) in enumerate(A):
		if c < 0:
			ans.append(j + ' ' + str(i + 1))
	for i in range(1, N):
		ans.append(str(i) + ' ' + str(i + 1))
else:
	for (i, c) in enumerate(A):
		if c > 0:
			ans.append(j + ' ' + str(i + 1))
	for i in range(N, 1, -1):
		ans.append(str(i) + ' ' + str(i - 1))
print(len(ans))
print('\n'.join(ans))


n = int(input())
A = list(map(int, input().split()))
ANS = []
B = A[:]
B.sort()
if abs(B[0]) > abs(B[-1]):
	absmax = B[0]
else:
	absmax = B[-1]
ind = A.index(absmax)
if absmax != 0:
	fugou = absmax // abs(absmax)
	for i in range(n):
		if A[i] * fugou < 0:
			ANS.append([ind + 1, i + 1])
	if fugou == 1:
		if ind + 1 != 1:
			ANS.append([ind + 1, 1])
		for i in range(n - 1):
			ANS.append([i + 1, i + 2])
	else:
		if ind + 1 != n:
			ANS.append([ind + 1, n])
		for i in range(n, 1, -1):
			ANS.append([i, i - 1])
	print(len(ANS))
	for i in range(len(ANS)):
		print('{} {}'.format(ANS[i][0], ANS[i][1]))
else:
	print(0)


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


n = int(input())
a = list(map(int, input().split()))
max_a = max(a)
min_a = min(a)
max_ind = a.index(max_a)
min_ind = a.index(min_a)
ans = []
if abs(max_a) >= abs(min_a):
	ans.append([max_ind + 1, 1])
	ans.append([max_ind + 1, 1])
	for i in range(n - 1):
		ans.append([i + 1, i + 2])
		ans.append([i + 1, i + 2])
else:
	ans.append([min_ind + 1, n])
	ans.append([min_ind + 1, n])
	for i in reversed(range(n - 1)):
		ans.append([i + 2, i + 1])
		ans.append([i + 2, i + 1])
print(len(ans))
for a in ans:
	print(*a)


n = int(input())
a = list(map(int, input().split()))
res = []
mx = max(a)
mx_idx = a.index(mx)
mn = min(a)
mn_idx = a.index(mn)
if abs(mx) >= abs(mn):
	for i in range(n):
		res.append((mx_idx, i))
	for i in range(0, n - 1):
		res.append((i, i + 1))
else:
	for i in range(n):
		res.append((mn_idx, i))
	for i in range(n - 1, 0, -1):
		res.append((i, i - 1))
print(len(res))
for (i, j) in res:
	print('%d %d' % (i + 1, j + 1))


n = int(input())
(*l,) = map(int, input().split())
(a, b) = (max(l), min(l))
(pa, pb) = (l.index(a), l.index(b))
print(2 * n - 1)
if abs(a) >= abs(b):
	for i in range(n):
		print(pa + 1, i + 1)
	for i in range(n - 1):
		print(i + 1, i + 2)
else:
	for i in range(n):
		print(pb + 1, i + 1)
	for i in range(n - 1):
		print(n - i, n - i - 1)


N = int(input())
a = list(map(int, input().split()))
a_abs = [abs(x) for x in a]
abs_max_index = a_abs.index(max(a_abs))
abs_max = a[abs_max_index]
print(2 * N)
for i in range(N):
	print('{} {}'.format(abs_max_index + 1, i + 1))
if abs_max >= 0:
	print('{} {}'.format(abs_max_index + 1, 1))
	for i in range(1, N):
		print('{} {}'.format(i, i + 1))
else:
	print('{} {}'.format(abs_max_index + 1, N))
	for i in range(N - 1):
		print('{} {}'.format(N - i, N - i - 1))


N = int(input())
a = list(map(int, input().split()))
mina = min(a)
maxa = max(a)
if mina == maxa:
	print(0)
	exit()
sousa = 0
index = 0
if abs(mina) <= abs(maxa):
	sousa = maxa
	index = a.index(maxa)
else:
	sousa = mina
	index = a.index(mina)
print(2 * N - 1)
for i in range(N):
	print(index + 1, i + 1)
if sousa >= 0:
	for i in range(N - 1):
		print(i + 1, i + 2)
else:
	for i in range(N, 1, -1):
		print(i, i - 1)


N = int(input())
A = list(map(int, input().split()))
(min_a, max_a) = (min(A), max(A))
(min_idx, max_idx) = (A.index(min_a) + 1, A.index(max_a) + 1)
ans = []
if abs(min_a) <= abs(max_a):
	for i in range(1, N + 1):
		ans.append([max_idx, i])
	for i in range(1, N):
		ans.append([i, i + 1])
else:
	for i in range(1, N + 1):
		ans.append([min_idx, i])
	for i in range(N, 1, -1):
		ans.append([i, i - 1])
print(len(ans))
for a in ans:
	print(*a)


N = int(input())
A = list(map(int, input().split()))
amax = max(A)
max_idx = A.index(amax)
amin = min(A)
min_idx = A.index(amin)
ans_list = []
if amax * amin < 0:
	if abs(amax) >= abs(amin):
		for i in range(N):
			A[i] += amax
			ans_list.append([max_idx + 1, i + 1])
	else:
		for i in range(N):
			A[i] += amin
			ans_list.append([min_idx + 1, i + 1])
amax = max(A)
amin = min(A)
if amax > 0:
	for i in range(N - 1):
		ans_list.append([i + 1, i + 2])
elif amin < 0:
	for i in range(N - 1, 0, -1):
		ans_list.append([i + 1, i])
print(len(ans_list))
for i in range(len(ans_list)):
	print(*ans_list[i])


def main():
	N = int(input())
	a = [int(s) for s in input().split(' ')]
	result = []
	max_a = max(a)
	min_a = min(a)
	if 0 <= max_a + min_a:
		k = a.index(max_a)
		sk = str(k + 1) + ' '
		for i in range(N):
			if a[i] < 0:
				result.append(sk + str(i + 1))
		for i in range(1, N):
			result.append(str(i) + ' ' + str(i + 1))
	else:
		k = a.index(min_a)
		sk = str(k + 1) + ' '
		for i in range(N):
			if a[i] > 0:
				result.append(sk + str(i + 1))
		for i in range(N - 1, 0, -1):
			result.append(str(i + 1) + ' ' + str(i))
	print(len(result))
	for s in result:
		print(s)
main()


N = int(input())
A = list(map(int, input().split()))
ABS = [abs(A[i]) for i in range(N)]
x = max(ABS)
ki = ABS.index(x)
ANSLIST = []
for i in range(ki):
	ANSLIST.append((ki + 1, i + 1))
for j in range(ki + 1, N):
	ANSLIST.append((ki + 1, j + 1))
if A[ki] > 0:
	for i in range(N - 1):
		ANSLIST.append((i + 1, i + 2))
elif A[ki] < 0:
	for i in range(N - 1, 0, -1):
		ANSLIST.append((i + 1, i))
print(len(ANSLIST))
for ans in ANSLIST:
	print(ans[0], ans[1])


N = int(input())
a = list(map(int, input().split()))
amin = min(a)
amax = max(a)
if abs(amin) < abs(amax):
	index = a.index(amax)
	a = list(map(lambda x: x + amax, a))
else:
	index = a.index(amin)
	a = list(map(lambda x: x + amin, a))
ans = [(index + 1, i + 1) for i in range(N)]
if a[0] > 0:
	ans += [(i + 1, i + 2) for i in range(N - 1)]
else:
	ans += [(i + 1, i) for i in range(N - 1, 0, -1)]
print(len(ans))
print('\n'.join(map(lambda xy: '%d %d' % xy, ans)))


n = int(input())
a = [int(x) for x in input().split()]
abs_a = [abs(x) for x in a]
max_index = abs_a.index(max(abs_a))
max_value = a[max_index]
judge = True if max_value > 0 else False
ans = []
for i in range(n):
	if judge and a[i] < 0:
		a[i] += a[max_index]
		ans.append((max_index + 1, i + 1))
	if not judge and a[i] > 0:
		a[i] += a[max_index]
		ans.append((max_index + 1, i + 1))
if max_value > 0:
	for i in range(n - 1):
		if a[i] > a[i + 1]:
			ans.append((i + 1, i + 2))
			a[i + 1] += a[i]
else:
	for i in range(n - 1, 0, -1):
		if a[i - 1] > a[i]:
			ans.append((i + 1, i))
			a[i - 1] += a[i]
print(len(ans))
for v in ans:
	print(*v)


def resolve():
	N = int(input())
	A = list(map(int, input().split()))
	(maximum, minimum) = (max(A), min(A))
	maxidx = A.index(maximum)
	minidx = A.index(minimum)
	ops = []
	for i in range(N):
		if abs(maximum) > abs(minimum):
			A[i] += maximum
			ops.append((maxidx, i))
		else:
			A[i] += minimum
			ops.append((minidx, i))
	if abs(maximum) > abs(minimum):
		for i in range(0, N - 1):
			ops.append((i, i + 1))
			A[i + 1] += A[i]
	else:
		for i in range(N - 1, 0, -1):
			ops.append((i, i - 1))
	print(len(ops))
	[print(v[0] + 1, v[1] + 1) for v in ops]
if '__main__' == __name__:
	resolve()


N = int(input())
A = list(map(int, input().split()))
max_A = -10 ** 9
max_num = 0
min_A = 10 ** 9
min_num = 0
for i in range(N):
	if max_A < A[i]:
		max_A = A[i]
		max_num = i
	if min_A > A[i]:
		min_A = A[i]
		min_num = i
if max_A > 0 and min_A < 0:
	if abs(max_A) >= abs(min_A):
		print(2 * N - 1)
		for i in range(N):
			A[i] += max_A
			print(max_num + 1, i + 1)
		for i in range(N - 1):
			print(i + 1, i + 2)
	else:
		print(2 * N - 1)
		for i in range(N):
			A[i] += min_A
			print(min_num + 1, i + 1)
		for i in range(N - 1, 0, -1):
			print(i + 1, i)
elif 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, 0, -1):
		print(i + 1, i)
else:
	print(0)


N = int(input())
A = list(map(int, input().split()))
rec = 0
ind = 0
mi = False
for i in range(N):
	if A[i] < 0 and abs(A[i]) > rec:
		rec = abs(A[i])
		ind = i
		mi = True
	elif A[i] > 0 and A[i] > rec:
		rec = A[i]
		ind = i
		mi = False
ans = []
if mi:
	for i in range(N):
		ans.append((ind + 1, i + 1))
	for i in range(N - 1, 0, -1):
		ans.append((i + 1, i))
else:
	for i in range(N):
		ans.append((ind + 1, i + 1))
	for i in range(1, N):
		ans.append((i, i + 1))
print(len(ans))
for i in ans:
	print(i[0], i[1])


N = int(input())
a = list(map(int, input().split()))
op = []
maxa = -10 ** 7
argmaxa = -1
for i in range(N):
	if a[i] > maxa:
		maxa = a[i]
		argmaxa = i
mina = 10 ** 7
argmina = -1
for i in range(N):
	if a[i] < mina:
		mina = a[i]
		argmina = i
if mina >= 0:
	pass
elif maxa <= 0:
	pass
elif abs(maxa) > abs(mina):
	for i in range(N):
		a[i] += maxa
		op.append((argmaxa, i))
else:
	for i in range(N):
		a[i] += mina
		op.append((argmina, i))
if abs(maxa) > abs(mina):
	for i in range(N - 1):
		a[i + 1] += a[i]
		op.append((i, i + 1))
else:
	for i in reversed(range(1, N)):
		a[i - 1] += a[i]
		op.append((i, i - 1))
print(len(op))
for elem in op:
	print(' '.join(map(lambda x: str(x + 1), elem)))


import sys
import math
from itertools import accumulate as acc
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
b = [abs(a[i]) for i in range(N)]
l = b.index(max(b))
if a[l] == 0:
	(print(0), sys.exit())
elif a[l] > 0:
	print(N * 2)
	for i in range(2):
		print(l + 1, 1)
	for i in range(1, N):
		for j in range(2):
			print(i, i + 1)
else:
	print(N * 2)
	for i in range(2):
		print(l + 1, N)
	for i in range(N, 1, -1):
		for j in range(2):
			print(i, i - 1)


(N, *A) = map(int, open(0).read().split())
ma = max(A)
mi = min(A)
if abs(mi) <= abs(ma):
	p = A.index(ma)
	ans = [(p, i) for i in range(N)]
	ans += [(i - 1, i) for i in range(1, N)]
else:
	p = A.index(mi)
	ans = [(p, i) for i in range(N)]
	ans += [(i, i - 1) for i in reversed(range(1, N))]
print(len(ans))
for (x, y) in ans:
	print(x + 1, y + 1)


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


import sys
from collections import deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline())
lst1 = list(map(int, readline().split()))
ans = []
if abs(max(lst1)) > abs(min(lst1)):
	a = lst1.index(max(lst1)) + 1
	for i in range(n):
		ans.append([a, i + 1])
	for i in range(n - 1):
		ans.append([i + 1, i + 2])
else:
	a = lst1.index(min(lst1)) + 1
	for i in range(n):
		ans.append([a, i + 1])
	for i in range(n - 1, 0, -1):
		ans.append([i + 1, i])
print(len(ans))
for (i, j) in ans:
	print(i, j)


import sys
read = sys.stdin.read
(n, *a) = map(int, read().split())

def output(x, y):
	print('{} {}'.format(x + 1, y + 1))
mx = max(a)
mxi = a.index(mx)
mn = min(a)
mni = a.index(mn)
print(2 * n - 1)
if abs(mx) >= abs(mn) and mx >= 0:
	for i in range(n):
		if mxi != i:
			output(mxi, i)
	output(mxi, mxi)
	for i in range(1, n):
		output(i - 1, i)
elif abs(mx) < abs(mn) and mn < 0:
	for i in range(n):
		if mni != i:
			output(mni, i)
	output(mni, mni)
	for i in range(n - 1, 0, -1):
		output(i, i - 1)


N = int(input())
a = [int(c) for c in input().split()]
M = max(a)
Mi = a.index(M)
m = min(a)
mi = a.index(m)
ans = []
if 0 <= m:
	for i in range(N - 1):
		ans += [(i + 1, i + 2)]
elif M <= 0:
	for i in range(N - 1, 0, -1):
		ans += [(i + 1, i)]
elif abs(m) < abs(M):
	for i in range(N):
		if a[i] < 0:
			ans += [(Mi + 1, i + 1)]
	for i in range(N - 1):
		ans += [(i + 1, i + 2)]
else:
	for i in range(N):
		if a[i] > 0:
			ans += [(mi + 1, i + 1)]
	for i in range(N - 1, 0, -1):
		ans += [(i + 1, i)]
print(len(ans))
for c in ans:
	print(*c)


N = int(input())
A = [int(_) for _ in input().split()]
B = [abs(a) for a in A]
absmaxv = -1
absmaxi = -1
for (i, v) in enumerate(B):
	if v > absmaxv:
		(absmaxi, absmaxv) = (i, v)
print(2 * N)
if A[absmaxi] > 0:
	print(absmaxi + 1, 1)
	print(absmaxi + 1, 1)
	for i in range(1, N):
		print(i, i + 1)
		print(i, i + 1)
else:
	print(absmaxi + 1, N)
	print(absmaxi + 1, 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()))
large = -float('inf')
small = float('inf')
for (i, a) in enumerate(A):
	if large < a:
		large = a
		idxL = i + 1
	if small > a:
		small = a
		idxS = i + 1
S = [(i + 1, i + 2) for i in range(N - 1)]
S_reverse = [(i, i - 1) for i in range(N, 1, -1)]
if small >= 0:
	ans = S
elif large <= 0:
	ans = S_reverse
elif abs(large) >= abs(small):
	ans = [(idxL, i) for i in range(1, N + 1) if i != idxL] + S
else:
	ans = [(idxS, i) for i in range(1, N + 1) if i != idxS] + S_reverse
print(len(ans))
for s in ans:
	print(*s)


N = int(input())
A = [int(x) for x in input().split()]
cnt = 0
a_max = max(A + [0])
a_min = min(A + [0])
cnt = 0
S = []
if a_max + a_min >= 0:
	k = A.index(a_max)
	while A[0] < a_max:
		A[0] += a_max
		cnt += 1
		S += [[k + 1, 1]]
	for i in range(N - 1):
		while A[i + 1] < A[i]:
			A[i + 1] += A[i]
			cnt += 1
			S += [[i + 1, i + 2]]
else:
	k = A.index(a_min)
	while A[-1] > a_min:
		A[-1] += a_min
		cnt += 1
		S += [[k + 1, N]]
	for i in range(N - 1, 0, -1):
		while A[i - 1] > A[i]:
			A[i - 1] += A[i]
			cnt += 1
			S += [[i + 1, i]]
print(cnt)
for s in S:
	print(s[0], s[1])


N = int(input())
a = list(map(int, input().split()))
print(2 * N - 2)
aa = list(map(abs, a))
nmax = aa.index(max(aa))
for i in range(N):
	if i == nmax:
		pass
	else:
		print('{} {}'.format(nmax + 1, i + 1))
if a[nmax] > 0:
	for i in range(N - 1):
		print('{} {}'.format(i + 1, i + 2))
else:
	for i in range(N - 1):
		print('{} {}'.format(N - i, N - i - 1))