#12:17
n = int(input())
a = list(map(int,input().split()))
plus = []
minus = []
for i in range(n):
  if a[i] >= 0:
    plus.append(a[i])
  else:
    minus.append(a[i])
plus.sort()
minus.sort(reverse=True)
lp = len(plus)
lm = len(minus)
if lp >= 1 and lm >= 1:
  ans = sum(plus) - sum(minus)
  print(ans)
  x = minus[0]
  lp = len(plus)
  for i in range(1,lp):
    print(x,plus[i])
    x = x - plus[i]
  minus[0] = x
  x = plus[0]
  for j in range(lm):
    print(x,minus[j])
    x = x - minus[j]
elif lp == 0:
  ans = - sum(minus) + 2 * max(minus)
  print(ans)
  x = minus[1]
  for j in range(2,lm):
    print(x,minus[j])
    x = x - minus[j]
  print(x,minus[0])
elif lm == 0:
  ans = sum(plus) - 2 * min(plus)
  print(ans)
  x = plus[0]
  for i in range(2,lp):
    print(x,plus[i])
    x = x - plus[i]
  print(plus[1],x) n = int(input()) n int(input()) int input() input a = list(map(int,input().split())) a list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split plus = [] plus [] minus = [] minus [] for i in range(n):
  if a[i] >= 0:
    plus.append(a[i])
  else:
    minus.append(a[i]) i range(n) range n if a[i] >= 0:
    plus.append(a[i])
  else:
    minus.append(a[i]) a[i] >= 0 a[i] a i 0 plus.append(a[i]) plus.append plus append a[i] a i minus.append(a[i]) minus.append minus append a[i] a i plus.sort() plus.sort plus sort minus.sort(reverse=True) minus.sort minus sort reverse=True reverse True lp = len(plus) lp len(plus) len plus lm = len(minus) lm len(minus) len minus if lp >= 1 and lm >= 1:
  ans = sum(plus) - sum(minus)
  print(ans)
  x = minus[0]
  lp = len(plus)
  for i in range(1,lp):
    print(x,plus[i])
    x = x - plus[i]
  minus[0] = x
  x = plus[0]
  for j in range(lm):
    print(x,minus[j])
    x = x - minus[j]
elif lp == 0:
  ans = - sum(minus) + 2 * max(minus)
  print(ans)
  x = minus[1]
  for j in range(2,lm):
    print(x,minus[j])
    x = x - minus[j]
  print(x,minus[0])
elif lm == 0:
  ans = sum(plus) - 2 * min(plus)
  print(ans)
  x = plus[0]
  for i in range(2,lp):
    print(x,plus[i])
    x = x - plus[i]
  print(plus[1],x) lp >= 1 and lm >= 1 lp >= 1 lp 1 lm >= 1 lm 1 ans = sum(plus) - sum(minus) ans sum(plus) - sum(minus) sum(plus) sum plus sum(minus) sum minus print(ans) print ans x = minus[0] x minus[0] minus 0 lp = len(plus) lp len(plus) len plus for i in range(1,lp):
    print(x,plus[i])
    x = x - plus[i]
   i range(1,lp) range 1 lp print(x,plus[i]) print x plus[i] plus i x = x - plus[i] x x - plus[i] x plus[i] plus i minus[0] = x minus[0] minus 0 x x = plus[0] x plus[0] plus 0 for j in range(lm):
    print(x,minus[j])
    x = x - minus[j] j range(lm) range lm print(x,minus[j]) print x minus[j] minus j x = x - minus[j] x x - minus[j] x minus[j] minus j elif lp == 0:
  ans = - sum(minus) + 2 * max(minus)
  print(ans)
  x = minus[1]
  for j in range(2,lm):
    print(x,minus[j])
    x = x - minus[j]
  print(x,minus[0]) lp == 0 lp 0 ans = - sum(minus) + 2 * max(minus) ans - sum(minus) + 2 * max(minus) - sum(minus) sum(minus) sum minus 2 * max(minus) 2 max(minus) max minus print(ans) print ans x = minus[1] x minus[1] minus 1 for j in range(2,lm):
    print(x,minus[j])
    x = x - minus[j]
   j range(2,lm) range 2 lm print(x,minus[j]) print x minus[j] minus j x = x - minus[j] x x - minus[j] x minus[j] minus j print(x,minus[0]) print x minus[0] minus 0 elif lm == 0:
  ans = sum(plus) - 2 * min(plus)
  print(ans)
  x = plus[0]
  for i in range(2,lp):
    print(x,plus[i])
    x = x - plus[i]
  print(plus[1],x) lm == 0 lm 0 ans = sum(plus) - 2 * min(plus) ans sum(plus) - 2 * min(plus) sum(plus) sum plus 2 * min(plus) 2 min(plus) min plus print(ans) print ans x = plus[0] x plus[0] plus 0 for i in range(2,lp):
    print(x,plus[i])
    x = x - plus[i]
   i range(2,lp) range 2 lp print(x,plus[i]) print x plus[i] plus i x = x - plus[i] x x - plus[i] x plus[i] plus i print(plus[1],x) print plus[1] plus 1 x x = x - plus[i] x - plus[i] x x = minus[1] minus[1] x x = plus[0] plus[0] x n = int(input()) int(input()) n lm = len(minus) len(minus) lm x = plus[0] plus[0] x minus = [] [] minus ans = - sum(minus) + 2 * max(minus) - sum(minus) + 2 * max(minus) ans x = x - minus[j] x - minus[j] x plus = [] [] plus lp = len(plus) len(plus) lp ans = sum(plus) - 2 * min(plus) sum(plus) - 2 * min(plus) ans x = minus[0] minus[0] x x = x - plus[i] x - plus[i] x lp = len(plus) len(plus) lp x = x - minus[j] x - minus[j] x a = list(map(int,input().split())) list(map(int,input().split())) a ans = sum(plus) - sum(minus) sum(plus) - sum(minus) ans
#12:17
n = int(input())
a = list(map(int,input().split()))
plus = []
minus = []
for i in range(n):
  if a[i] >= 0:
    plus.append(a[i])
  else:
    minus.append(a[i])
plus.sort()
minus.sort(reverse=True)
lp = len(plus)
lm = len(minus)
if lp >= 1 and lm >= 1:
  ans = sum(plus) - sum(minus)
  print(ans)
  x = minus[0]
  lp = len(plus)
  for i in range(1,lp):
    print(x,plus[i])
    x = x - plus[i]
  minus[0] = x
  x = plus[0]
  for j in range(lm):
    print(x,minus[j])
    x = x - minus[j]
elif lp == 0:
  ans = - sum(minus) + 2 * max(minus)
  print(ans)
  x = minus[1]
  for j in range(2,lm):
    print(x,minus[j])
    x = x - minus[j]
  print(x,minus[0])
elif lm == 0:
  ans = sum(plus) - 2 * min(plus)
  print(ans)
  x = plus[0]
  for i in range(2,lp):
    print(x,plus[i])
    x = x - plus[i]
  print(plus[1],x)