Buggy python submission (verdict: Runtime Error):
n = int(input())
x = list(map(int,input().split()))
#x = sorted(list(map(int,input().split())),reverse=True)
#nmax = max(x)
#ans = 2*nmax-sum(x)
lst = []

  
nmi = min(x)
nma = max(x)
del x[x.index(nmi)]
del x[x.index(nma)]

while max(x) > -1:
  mi = min(x)
  ma = max(x)
  lst.append(str(mi)+" "+str(ma))
  del x[x.index(mi)]
  del x[x.index(ma)]
  x.append(mi - ma)

for i in range(len(x)):
  lst.append(nma+" "+i)
  nma += i
print(nmi - nma)
for i in range(len(lst)):
  print(lst[i])
print(nmi,nma)

Fixed submission:
n = int(input())
x = list(map(int,input().split()))
#x = sorted(list(map(int,input().split())),reverse=True)
#nmax = max(x)
#ans = 2*nmax-sum(x)
lst = []

  
nmi = min(x)
nma = max(x)
del x[x.index(nmi)]
del x[x.index(nma)]

mainus = [i for i in x if i < 0]
plus = [i for i in x if i >= 0]
for i in mainus:
  lst.append(str(nma)+" "+str(i))
  nma -= i
for i in plus:
  lst.append(str(nmi)+" "+str(i))
  nmi -= i
lst.append(str(nma)+" "+str(nmi))
print(nma-nmi)
for i in lst:
  print(i)
"""
while max(x) > -1 and len(x) > 1:
  mi = min(x)
  ma = max(x)
  lst.append(str(mi)+" "+str(ma))
  del x[x.index(mi)]
  del x[x.index(ma)]
  x.append(mi - ma)

for i in range(len(x)):
  lst.append(str(nma)+" "+str(i))
  nma += i
print(nmi - nma)
for i in range(len(lst)):
  print(lst[i])
print(nmi,nma)
"""

Buggy python submission (verdict: Runtime Error):
n = int(input())
x = list(map(int,input().split()))
#x = sorted(list(map(int,input().split())),reverse=True)
#nmax = max(x)
#ans = 2*nmax-sum(x)
lst = []


while len(x) > 2:
  mi = min(x)
  ma = max(x)
  if mi < 0:
    lst.append(str(ma)+" "+str(mi))
    del x[x.index(mi)]
    del x[x.index(ma)]
    x.append(ma - mi)
  lst.append(str(ma)+" "+str(mi))
  del x[x.index(mi)]
  del x[x.index(ma)]
  x.append(mi - ma)

print(max(x) - min(x))
for i in range(len(lst)):
  print(lst[i])
print(max(x),min(x))

Fixed submission:
n = int(input())
x = list(map(int,input().split()))
#x = sorted(list(map(int,input().split())),reverse=True)
#nmax = max(x)
#ans = 2*nmax-sum(x)
lst = []

  
nmi = min(x)
nma = max(x)
del x[x.index(nmi)]
del x[x.index(nma)]

mainus = [i for i in x if i < 0]
plus = [i for i in x if i >= 0]
for i in mainus:
  lst.append(str(nma)+" "+str(i))
  nma -= i
for i in plus:
  lst.append(str(nmi)+" "+str(i))
  nmi -= i
lst.append(str(nma)+" "+str(nmi))
print(nma-nmi)
for i in lst:
  print(i)
"""
while max(x) > -1 and len(x) > 1:
  mi = min(x)
  ma = max(x)
  lst.append(str(mi)+" "+str(ma))
  del x[x.index(mi)]
  del x[x.index(ma)]
  x.append(mi - ma)

for i in range(len(x)):
  lst.append(str(nma)+" "+str(i))
  nma += i
print(nmi - nma)
for i in range(len(lst)):
  print(lst[i])
print(nmi,nma)
"""

Buggy python submission (verdict: Runtime Error):
n = int(input())
x = list(map(int,input().split()))
#x = sorted(list(map(int,input().split())),reverse=True)
#nmax = max(x)
#ans = 2*nmax-sum(x)
lst = []


while len(x) > 2:
  mi = min(x)
  ma = max(x)
  if mi < 0:
    lst.append(str(ma)+" "+str(mi))
    del x[x.index(mi)]
    del x[x.index(ma)]
    x.append(ma - mi)
    lst.append(str(ma)+" "+str(mi))
  del x[x.index(mi)]
  del x[x.index(ma)]
  x.append(mi - ma)

print(max(x) - min(x))
for i in range(len(lst)):
  print(lst[i])
print(max(x),min(x))

Fixed submission:
n = int(input())
x = list(map(int,input().split()))
#x = sorted(list(map(int,input().split())),reverse=True)
#nmax = max(x)
#ans = 2*nmax-sum(x)
lst = []

  
nmi = min(x)
nma = max(x)
del x[x.index(nmi)]
del x[x.index(nma)]

mainus = [i for i in x if i < 0]
plus = [i for i in x if i >= 0]
for i in mainus:
  lst.append(str(nma)+" "+str(i))
  nma -= i
for i in plus:
  lst.append(str(nmi)+" "+str(i))
  nmi -= i
lst.append(str(nma)+" "+str(nmi))
print(nma-nmi)
for i in lst:
  print(i)
"""
while max(x) > -1 and len(x) > 1:
  mi = min(x)
  ma = max(x)
  lst.append(str(mi)+" "+str(ma))
  del x[x.index(mi)]
  del x[x.index(ma)]
  x.append(mi - ma)

for i in range(len(x)):
  lst.append(str(nma)+" "+str(i))
  nma += i
print(nmi - nma)
for i in range(len(lst)):
  print(lst[i])
print(nmi,nma)
"""