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
    c = if (x - y).abs > (y - x).abs
          [x, y]
        elsif (x - y).abs < (y - x).abs
          [y, x]
        elsif (x - y).abs == (y - x).abs
          if numbers[-1] <= -1 
            x-y >= y-x ? [x, y] : [y, x]
          else
            [x, y]
          end
        end
    
    diff =  c[0] - c[1]
    combi << [c[0],c[1]]
    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