n = gets.to_i
as = gets.split.map(&:to_i).sort

progress = []
while as.size>=2
  if as.size>=3 && as[-2]>0
    x2, x1 = as.pop(2)
    y = as.shift
    t = y - x2
    progress << [y, x2]
    as.push(x1 - t)
    progress << [x1, t]
  else
    x = as.pop
    y = as.shift
    progress << [x, y]
    as.push(x - y)
  end
end
p as[0]
progress.each{|x, y| puts "#{x} #{y}"}
