M = gets.chop.to_i
nums = gets.chop.split.map(&:to_i)

nums.sort!

max_num = nums.pop
min_num = nums.shift

process = []
while !nums.empty? && nums[0] <= 0
  num = nums.shift
  process << "#{max_num} #{num}"
  max_num -= num
end

nums.each do |n|
  process << "#{min_num} #{n}"
  min_num	-= n
end

process << "#{max_num} #{min_num}"
max_num -= min_num

puts max_num
puts process.join("\n")