Buggy python submission (verdict: Runtime Error):
import random
import copy
n = input()
ori = map(int, raw_input().split())
num = copy.deepcopy(ori)
while not sorted(num) == num:
    l = list()
    for i in xrange(n*2):
        if sorted(num) == num:
            break
        a = random.randint(0, n-1)
        b = random.randint(0, n-1)
        num[b] += num[a]
        l.append("%d %d" % ((a+1), (b+1)))
    else:
        num = copy.deepcopy(ori)

print len(l)
for i in l:
    print i
print num


Fixed submission:
n = input()
num = map(int, raw_input().split())
ma = max(num)
mi = min(num)
l = list()
if ma*mi < 0:
    if ma > abs(mi):
        index = num.index(ma)
    else:
        index = num.index(mi)
    for i in xrange(n):
        l.append("%d %d" % (index+1, i+1))
    b = num[index]
else:
    b = 0
    for i in num:
        if i:
            b = i
            break

if b == 0:
    pass
elif b < 0:
    for i in xrange(n-1, 0, -1):
        l.append("%d %d" % (i+1, i))
else:
    for i in xrange(0, n-1):
        l.append("%d %d" % (i+1, i+2))

print len(l)
for i in l:
    print i

Buggy python submission (verdict: Runtime Error):
import random
import copy
n = input()
ori = map(int, raw_input().split())
num = copy.deepcopy(ori)
while not sorted(num) == num:
    l = list()
    for i in xrange(n*2):
        if sorted(num) == num:
            break
        a = random.randint(0, n-1)
        b = random.randint(0, n-1)
        num[a] += num[b]
        l.append("%d %d" % ((a+1), (b+1)))
    else:
        num = copy.deepcopy(ori)

print len(l)
for i in l:
    print i


Fixed submission:
n = input()
num = map(int, raw_input().split())
ma = max(num)
mi = min(num)
l = list()
if ma*mi < 0:
    if ma > abs(mi):
        index = num.index(ma)
    else:
        index = num.index(mi)
    for i in xrange(n):
        l.append("%d %d" % (index+1, i+1))
    b = num[index]
else:
    b = 0
    for i in num:
        if i:
            b = i
            break

if b == 0:
    pass
elif b < 0:
    for i in xrange(n-1, 0, -1):
        l.append("%d %d" % (i+1, i))
else:
    for i in xrange(0, n-1):
        l.append("%d %d" % (i+1, i+2))

print len(l)
for i in l:
    print i

Buggy python submission (verdict: Runtime Error):
import random
import copy
n = input()
ori = map(int, raw_input().split())
num = copy.deepcopy(ori)
while not sorted(num) == num:
    l = list()
    for i in xrange(n*2):
        if sorted(num) == num:
            break
        a = random.randint(0, n-1)
        b = random.randint(0, n-1)
        num[a] += num[b]
        l.append("%d %d" % ((a+1), (b+1)))
    else:
        num = copy.deepcopy(ori)

print len(l)
for i in l:
    print i
print num


Fixed submission:
n = input()
num = map(int, raw_input().split())
ma = max(num)
mi = min(num)
l = list()
if ma*mi < 0:
    if ma > abs(mi):
        index = num.index(ma)
    else:
        index = num.index(mi)
    for i in xrange(n):
        l.append("%d %d" % (index+1, i+1))
    b = num[index]
else:
    b = 0
    for i in num:
        if i:
            b = i
            break

if b == 0:
    pass
elif b < 0:
    for i in xrange(n-1, 0, -1):
        l.append("%d %d" % (i+1, i))
else:
    for i in xrange(0, n-1):
        l.append("%d %d" % (i+1, i+2))

print len(l)
for i in l:
    print i

Buggy python submission (verdict: Runtime Error):
import random
n = input()
num = map(int, raw_input().split())
while not sorted(num) == num:
    l = list()
    for i in xrange(n*2):
        if sorted(num) == num:
            break
        a = random.randint(0, n-1)
        b = random.randint(0, n-1)
        num[a] += num[b]
        l.append("%d %d" % ((a+1), (b+1)))

print len(l)
for i in l:
    print i


Fixed submission:
n = input()
num = map(int, raw_input().split())
ma = max(num)
mi = min(num)
l = list()
if ma*mi < 0:
    if ma > abs(mi):
        index = num.index(ma)
    else:
        index = num.index(mi)
    for i in xrange(n):
        l.append("%d %d" % (index+1, i+1))
    b = num[index]
else:
    b = 0
    for i in num:
        if i:
            b = i
            break

if b == 0:
    pass
elif b < 0:
    for i in xrange(n-1, 0, -1):
        l.append("%d %d" % (i+1, i))
else:
    for i in xrange(0, n-1):
        l.append("%d %d" % (i+1, i+2))

print len(l)
for i in l:
    print i