# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
nn = 0
while l = $stdin.gets do
  if lc == 0
    nn = l.chomp.to_i
  else
    inputs = l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# body
if $debugFlag
  p nn
  p inputs
end

inputs.sort!
res = []

for i in 1..inputs.size-2 do
  if inputs[i] > 0
    res << "#{inputs[0]} #{inputs[i]}"
    inputs[0] -= inputs[i]
  else
    res << "#{inputs[-1]} #{inputs[i]}"
    inputs[-1] -= inputs[i]
  end
end

res << "#{inputs[-1]} #{inputs[0]}"
puts inputs[-1] - inputs[0]
res.each do |r_i|
  puts r_i
end
