Buggy python submission (verdict: Runtime Error):
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)**(max(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


Fixed submission:
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

Buggy python submission (verdict: Runtime Error):
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)**(max(A) < 0)]:
    l, r = A[i], A[i + 1]

    if l > r:
        if r <= 0 <= l:
            if l * r < 0:
                exit()
        if r > 0:
            A[i + 1] += l
            ans.append((i, i + 1))
        if 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


Fixed submission:
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

Buggy python submission (verdict: Runtime Error):
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)**(max(A) < 0)]:
    l, r = A[i], A[i + 1]

    if l > r:
        if r >= 0:
            A[i + 1] += l
            ans.append((i, i + 1))
        if 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


Fixed submission:
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

Buggy python submission (verdict: Runtime Error):
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))


if max(A) * min(A) < 0:
    exit()

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

    if l > r:
        if r > 0:
            A[i + 1] += l
            ans.append((i, i + 1))
        if 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


Fixed submission:
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

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

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

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)**(max(A) < 0)]:
    l, r = A[i], A[i + 1]

    if l > r:
        if r > 0:
            A[i + 1] += l
            ans.append((i, i + 1))
        if 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


Fixed submission:
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

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

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

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

if max(A) * min(A) < 0:
    exit()

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

    if l > r:
        if r > 0:
            A[i + 1] += l
            ans.append((i, i + 1))
        if 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


Fixed submission:
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

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

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

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))
if abs(mx) >= abs(mi):
    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):
    l, r = A[i], A[i + 1]

    if l > r:
        if r > 0:
            A[i + 1] += l
            ans.append((i, i + 1))
        if 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


Fixed submission:
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

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

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

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))
if abs(mx) > abs(mi):
    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):
    l, r = A[i], A[i + 1]

    if l > r:
        if r > 0:
            A[i + 1] += l
            ans.append((i, i + 1))
        if 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


Fixed submission:
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

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

ans = []

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

    if l > r:
        addR = None

        if 0 < r:
            addR = True

        if l < 0:
            addR = False

        if r <= 0 <= l:
            if abs(l) >= abs(r):
                addR = True
            else:
                addR = False

        if addR:
            A[i + 1] += l * 2
            ans.append((i, i + 1))
            ans.append((i, i + 1))
        else:
            A[i] += r * 2
            ans.append((i + 1, i))
            ans.append((i + 1, i))

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

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


Fixed submission:
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