n = gets.to_i
a = gets.split.map(&:to_i).sort

ary = []
if n.odd?
    m = a[n/2]
    (n/2).times do |i|
        ary << "#{a[i]} #{a[-i-1]}"
        x = a[i] - a[-i-1]
        ary << "#{m} #{x}"
        m -= x
    end
else
    ary << "#{a[-1]} #{a[0]}"
    m = a[-1] - a[0]
    1.upto(n/2-1) do |i|
        ary << "#{a[i] - a[-i-1]}"
        x = a[i] - a[-i-1]
        ary << "#{m} #{x}"
        m -= x
    end
end

puts m, ary