def main
  n = gets.chomp.to_i
  numbers = gets.chomp.split(' ').map(&:to_i).sort
  
  combi = []

  (n-2).times do |_i|
    x = numbers.shift
    y = numbers.pop
    diff = x - y
    combi << [x,y]
    if numbers[-1] <= diff
      numbers.push(diff)
    else
      numbers.unshift(diff)
    end
  end

  combi << [numbers[1], numbers[0]]
  numbers = numbers[1] - numbers[0]
  
  puts numbers
  combi.each {|x,y| puts"#{x} #{y}" }
end


main