

N = gets.to_i
#aa, bb = gets.split.map(&:to_i).partition{|x|x<0}

#p aa.sort_by!{|x|-x}
#p bb.sort_by!{|x|x}
#return
aa = gets.split.map(&:to_i).sort_by(&:abs)
#p aa

t= aa.shift
res = t
#p [res,aa]
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],1]
	else
		resa << [resa[-1][1]-a,a-resa[-1][1],2]
	end
end

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

	#	end

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