include Math

n = gets.to_i
ary = Array.new(log(n, 2) + 2).map{Array.new}
ary[0] = gets.split.map(&:to_i).sort

ans = []
sum = 0

if n % 2 == 1 && ary[0][n / 2] > 0
  no1 = false
else
  no1 = true
end
  
while ary[0].size > 1

  x = ary[0].shift
  y = ary[0].pop
  
  if no1 == true
    ans << [y, x]
    ary[1] << y - x
    no1 = false
  else 
    ans << [x, y]
    ary[1] << x - y
  end

end

if ary[0].size == 1
  ary[1].unshift(ary[0].shift)
end

while ary[1].size > 1
  x = ary[1].shift
  y = ary[1].shift
 
  ary[1].unshift(x - y)
  ans << [x, y]
end

puts ary[1]
ans.each do |a|
  puts a.join(" ")
end
