Time limit
2s
Memory limit
128 MB
N people will sit around a circular table. Each person wants the height difference between them and each neighbor to be as small as possible.
For an arrangement, define its discomfort as the maximum height difference among all adjacent pairs around the circle. When the N heights are printed in one line, treat that order as the clockwise seating order.
Print a clockwise arrangement whose discomfort is as small as possible. If there are several such arrangements, print the lexicographically smallest sequence.
The first line contains the number of people N. N is an integer from 3 to 50.
The second line contains the N heights. Each height is a positive integer not greater than 1000.
Print one clockwise arrangement with minimum discomfort on the first line, with heights separated by spaces. If several arrangements are possible, print the lexicographically smallest sequence.