

N = gets.to_i

aa = gets.split.map(&:to_i).sort_by(&:abs) 
t= aa.shift
resa = [[t,t]]


aa.each do |a|
	if (resa[-1][0]-a).abs > (resa[-1][1]-a).abs
		resa << [resa[-1][0]-a,a-resa[-1][0]]
	else
		resa << [resa[-1][1]-a,a-resa[-1][1]]
	end
end

s = resa.pop[0].abs
p s
res = []
resa.reverse_each{|x|
	t = aa.pop
	if t - x[0] == s
		res.unshift [ t,s=x[0]]
	elsif t - x[1] == s
		res.unshift [t, s=x[1]]
	elsif x[0] - t == s
		res.unshift [s=x[0], t]
	else
		res.unshift [s=x[1], t]
	end


}
res.each{|x|puts x*" "}
