#C9302. Minimize Consecutive Differences
Minimize Consecutive Differences
Minimize Consecutive Differences
You are given a list of N integers. Your task is to rearrange the list so that the difference between any two consecutive integers is minimized. In other words, after rearrangement, the list should be sorted in ascending order.
The solution for this problem is straightforward since a sorted list automatically minimizes the difference between adjacent numbers. For example, given the list [4, 2, 1, 6, 3], the optimal rearrangement is [1, 2, 3, 4, 6].
inputFormat
The input is given via standard input (stdin) and consists of two lines. The first line contains an integer N representing the number of integers. The second line contains N space-separated integers.
outputFormat
Output the rearranged list in ascending order as a single line. The integers should be space-separated.
## sample5
4 2 1 6 3
1 2 3 4 6
</p>