n = gets.to_i
a = gets.split(" ").map{|k|k.to_i}
a = a.sort
ans_arr = []
ans_num = a[0]
(a.size-2).times{|i|
    ans_arr.push(ans_num,a[n-1-1-i])
    ans_num = ans_num-a[n-1-1-i]
}
ans_arr.push(a[-1],ans_num)
puts "#{a[-1]-ans_num}"
ans_arr.each{|k|
    puts "#{k[0]} #{k[1]}"
}