require 'pp'

n= gets.chomp!.to_i
a_n = gets.chomp!.split(" ").map!(&:to_i)
a_n.sort!

ans = []

while a_n.length != 1
    head = a_n.shift
    tail = a_n.pop
    ans << "#{head} #{tail}"
    if a_n.empty?
       a_n.unshift(tail - head)
    else
       a_n.unshift(head - tail)
    end
end

puts a_n[0]
puts ans
