#C9209. Minimize Absolute Difference

    ID: 53277 Type: Default 1000ms 256MiB

Minimize Absolute Difference

Minimize Absolute Difference

You are given an integer n and an array of n integers. Your task is to rearrange the array such that the absolute difference between any two adjacent elements is minimized. In other words, you are required to minimize the quantity

i=1n1ai+1ai,\sum_{i=1}^{n-1} |a_{i+1} - a_i|,

which is naturally achieved by outputting the array in non-decreasing order.

Example: For the input array [3, 2, 1, 4], the rearranged order should be [1, 2, 3, 4].

inputFormat

The first line contains a single integer n representing the number of elements in the array. The second line contains n space-separated integers which constitute the array.

outputFormat

Output a single line containing the rearranged array, where the elements are sorted in non-decreasing order and separated by a single space.

## sample
4
3 2 1 4
1 2 3 4