n = gets.chomp.to_i
a_arr = gets.chomp.split(" ").map(&:to_i).sort

puts_arr = []

(n-1).times do
  min = a_arr[0]
  max = a_arr[-1]
  if a_arr.length == 2 then
    puts_arr << "#{max} #{min}"
    puts max - min
    break
  end

  if max.abs >= min.abs then
    x = a_arr[0]
    y = a_arr[-2]
    a_arr.delete_at(0)
    a_arr.delete_at(-2)
  else
    x = a_arr[-1]
    y = a_arr[1]
    a_arr.delete_at(-1)
    a_arr.delete_at(1)
  end
  puts_arr << "#{x} #{y}"
  diff = x - y
  flag = false
  if diff <= a_arr[0] then
    a_arr.unshift(diff)
  elsif diff >= a_arr[-1]
    a_arr.push(diff)
  else
    a_arr.each_with_index do |a, i|
      if diff >= a then
        a_arr.insert(i+1, diff)
        break
      end
    end
  end
end

puts_arr.each do |str|
  puts str
end



