N = gets.to_i
arr = gets.split.map(&:to_i)

if N == 2
  arr.sort!
  puts arr[1] - arr[0]
  return
end

logs = []

arr.sort!
min = arr.shift
max = arr.pop
arr.each do |i|
  if i > 0
    logs.push([min, i])
    min -= i
  else
    logs.push([max, i])
    max -= i
  end
end
puts max - min
logs.each { |log| puts "#{log[0]} #{log[1]}"}
puts "#{max} #{min}"