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[1].size == 1
    if i == 0
      ary[1].unshift(ary[i].shift)
    else
      ary[1] << ary[i].shift
    end
  end

p ary[0]
while ary[1].size > 2
x = ary[1].shift
y = ary[1].shift
ary[1].unshift(x - y)
p ary[1]
end

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