IntermediateRating 1400
Elevator Scheduling
An elevator at floor f first goes up serving all requested floors above it in increasing order, then down serving the rest in decreasing order. Print the order of floors and the total distance.
Input
f, then a line of requested floors.
Output
Two lines.
Sample 1
Input
5 8 2 6 1 9
Output
6 8 9 2 1 12
Sample 2
Input
0 3 1 2
Output
1 2 3 3
Output appears here