require 'stringio'
gets
a = gets.split.map(&:to_i).sort
a_min = a.shift
m = a.shift
s = StringIO.new
a.reverse_each do |a_max|
  s.puts [a_min, a_max].join(' ')
  a_min -= a_max
end
s.puts [m, a_min].join(' ')
puts m - a_min
puts s.string