n = int(input())
ai = [int(x) for x in input().split()]

ai.sort()

temp = [abs(x) for x in ai[1:-1]]

o1 = -ai[0] + sum(temp) + ai[-1]

print(o1)

temp1 = ai.pop(-1)
num_p = sum(x >= 0 for x in ai)
if num_p == len(ai):
  num_p -= 1
for i in range(num_p):
  temp2 = ai.pop(-1)
  print(ai[0], temp2)
  ai[0] -= temp2

for i in range(len(ai)):
  temp2 = ai.pop(0)
  print(temp1, temp2)
  temp1 -= temp2
  n = int(input()) n int(input()) int input() input int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x ai = [int(x) for x in input().split()] ai [int(x) for x in input().split()] ai.sort() ai.sort ai sort abs(x) for x in ai[1:-1] for x in ai[1:-1] x ai[1:-1] ai 1:-1 1 -1 for x in ai[1:-1] abs(x) abs x temp = [abs(x) for x in ai[1:-1]] temp [abs(x) for x in ai[1:-1]] o1 = -ai[0] + sum(temp) + ai[-1] o1 -ai[0] + sum(temp) + ai[-1] -ai[0] + sum(temp) -ai[0] ai[0] ai 0 sum(temp) sum temp ai[-1] ai -1 print(o1) print o1 temp1 = ai.pop(-1) temp1 ai.pop(-1) ai.pop ai pop -1 num_p = sum(x >= 0 for x in ai) num_p sum(x >= 0 for x in ai) sum x >= 0 x 0 if num_p == len(ai):
  num_p -= 1 num_p == len(ai) num_p len(ai) len ai num_p -= 1 num_p 1 for i in range(num_p):
  temp2 = ai.pop(-1)
  print(ai[0], temp2)
  ai[0] -= temp2 i range(num_p) range num_p temp2 = ai.pop(-1) temp2 ai.pop(-1) ai.pop ai pop -1 print(ai[0], temp2) print ai[0] ai 0 temp2 ai[0] -= temp2 ai[0] ai 0 temp2 for i in range(len(ai)):
  temp2 = ai.pop(0)
  print(temp1, temp2)
  temp1 -= temp2
  i range(len(ai)) range len(ai) len ai temp2 = ai.pop(0) temp2 ai.pop(0) ai.pop ai pop 0 print(temp1, temp2) print temp1 temp2 temp1 -= temp2 temp1 temp2 num_p -= 1 1 num_p temp2 = ai.pop(-1) ai.pop(-1) temp2 ai = [int(x) for x in input().split()] [int(x) for x in input().split()] ai o1 = -ai[0] + sum(temp) + ai[-1] -ai[0] + sum(temp) + ai[-1] o1 temp = [abs(x) for x in ai[1:-1]] [abs(x) for x in ai[1:-1]] temp temp2 = ai.pop(0) ai.pop(0) temp2 temp1 -= temp2 temp2 temp1 temp1 = ai.pop(-1) ai.pop(-1) temp1 num_p = sum(x >= 0 for x in ai) sum(x >= 0 for x in ai) num_p n = int(input()) int(input()) n
n = int(input())
ai = [int(x) for x in input().split()]

ai.sort()

temp = [abs(x) for x in ai[1:-1]]

o1 = -ai[0] + sum(temp) + ai[-1]

print(o1)

temp1 = ai.pop(-1)
num_p = sum(x >= 0 for x in ai)
if num_p == len(ai):
  num_p -= 1
for i in range(num_p):
  temp2 = ai.pop(-1)
  print(ai[0], temp2)
  ai[0] -= temp2

for i in range(len(ai)):
  temp2 = ai.pop(0)
  print(temp1, temp2)
  temp1 -= temp2
 
