n=gets.to_i
a=gets.split.map(&:to_i)
@aa = Array.new(3).map{[]}
a.each do |e|
  @aa[(e<=>0)+1] << e
end
@aa.map!(&:sort)

@r = []
def pp
  if @aa[0].size >= 2
    a = @aa[2].pop
    b = @aa[0].pop
    @aa[2] << a-b
    @r << [a,b]
    return true
  elsif @aa[2].size >= 2
    a = @aa[0].pop
    b = @aa[2].pop
    @aa[0] << a-b
    @r << [a,b]
    return true
  elsif @aa[0].size!=0 && @aa[2].size!=0
    a = @aa[2].pop
    b = @aa[0].pop
    @aa[2] << a-b
    @r << [a,b]
    return false
  else
    if @aa[0].size==1
      @aa[2] << @aa[0].pop*-1
      r = @r.pop
      @r << [r[1], r[0]]
    end
    return false
  end
end

while @aa[1].pop
  if @aa[0].size < @aa[2].size
    @aa[0].unshift(0)
  else
    @aa[2].unshift(0)
  end
end

if @aa[0].size.zero?
  a = @aa[2].shift
  b = @aa[2].shift
  @aa[0] << a-b
  @r << [a,b]
elsif @aa[2].size.zero?
  a = @aa[0].shift
  b = @aa[0].shift
  @aa[2] << b-a
  @r << [b,a]
end


while pp
end


puts @aa[2][0]
puts @r.map{|m|m.join(' ')}
