N = gets.chomp.to_i
A = gets.chomp.split(' ').map(&:to_i)[0..N].sort
positives, negatives = A.partition{ |v| v > 0 }

min = A.min
max = A.max

puts (if min > 0
  A.reduce(&:+) - min*2
elsif max < 0
  max*2 - A.reduce(&:+)
else
  positives.reduce(0, &:+) - negatives.reduce(0, &:+)
end)

(N-1).times do |i|
  a, b = begin
    if positives.size == 2 && negatives.size == 0
      [ positives.pop, positives.shift ]
    elsif positives.size == 0 && negatives.size == 2
      [ negatives.shift, negatives.pop ]
    elsif positives.size > 1
      [ (negatives.empty? ? positives : negatives).shift, positives.shift ]
    else
      [ (positives.empty? ? negatives : positives).pop, negatives.shift ]
    end
  end
  if a > b 
    positives.push(a - b)
  else
    negatives.unshift(a - b)
  end
  puts [a, b].join(" ")
end
