n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
am, az, ap = [], [], []
n.times do |i|
  if a[i] < 0
    am << a[i]
  elsif a[i] == 0
    az << a[i]
  else
    ap << a[i]
  end
end
if am != [] && ap != []
  puts ap.inject(:+) + am.inject(:+) * (-1)
  m = am[0]
  (ap.length-1).times do |i|
    puts "#{m} #{ap[i]}"
    m -= ap[i]
  end
  puts "#{ap[-1]} #{m}"
  m = ap[-1] - m
  (am.length-1).times do |i|
    puts "#{m} #{am[i+1]}"
    m -= ap[i+1]
  end
  az.length.times do
    puts "#{m} 0"
  end
elsif am == [] && ap == []
  puts 0
  (az.length-1).times do
    puts "0 0"
  end
elsif am == []
  if az != []
    puts ap.inject(:+)
    m = 0
    (ap.length-1).times do |i|
      puts "#{m} #{ap[i]}"
      m -= ap[i]
    end
    puts "#{ap[-1]} #{m}"
    m = ap[-1] - m
    (az.length-1).times do
      puts "#{m} 0"
    end
  else
    ap.sort!
    puts ap.inject(:+) - ap[0] * 2
    m = ap[0]
    (ap.length-2).times do |i|
      puts "#{m} #{ap[i+1]}"
      m -= ap[i+1]
    end
    puts "#{ap[-1]} #{m}"
  end
else
  if az != []
    puts am.inject(:+) * (-1)
    m = 0
    (am.length).times do |i|
      puts "#{m} #{am[i]}"
      m -= am[i]
    end
    (az.length-1).times do
      puts "#{m} 0"
    end
  else
    am.sort!.reverse!
    puts (am.inject(:+) - am[0] * 2) * (-1)
    m = am[0]
    (am.length-1).times do |i|
      puts "#{m} #{am[i+1]}"
      m -= a[i+1]
    end
  end
end
