n=gets.chomp.to_i
x=[]
for a in 1..n
  x<<gets.chomp.to_i
end
x.sort!
y=[]
for b in 1..n
  if b.odd?
    y<<x.pop
  else
    y<<x.shift
  end
end
z=[]
z<<y.pop
for c in 1..n-1
  z<<y.shift
end
puts "#{z}"
result=0
for d in 1..n-1
  diff=z[d]-z[d-1]
  puts diff.abs
  result=result+diff.abs
end
puts "#{result}"
