n = gets.to_i
as = gets.split.map(&:to_i).sort
c_minus = [[as.select{|x|x<=0}.size, n-1].min, n/2].max
bs = as.shift(c_minus)
puts as.reduce(:+) - bs.reduce(:+)
while as.size >= 2 and bs.size >= 1
  x1, x2 = as.pop(2)
  y = bs.pop
  puts "#{y} #{x1}"
  puts "#{x2} #{y-x1}"
  as.push(x2 - (y - x1))
end
x = as[0]
until bs.empty?
  y = bs.pop
  puts "#{x} #{y}"
  x -= y
end