#K70737. Minimize Absolute Differences

    ID: 33375 Type: Default 1000ms 256MiB

Minimize Absolute Differences

Minimize Absolute Differences

You are given an array \(a = (a_1,a_2,\dots,a_n)\) of \(n\) integers. Your task is to rearrange the array into a permutation \(b = (b_1,b_2,\dots,b_n)\) such that the sum of absolute differences

[ S = \sum_{i=1}^{n} |b_i - a_i| ]

is minimized. It can be proven that the optimal solution is to simply sort the array in non-decreasing order. Write a program that reads the array, computes its sorted order, and outputs the result.

Example:

Input:
5
1 3 2 3 1

Output: 1 1 2 3 3

</p>

inputFormat

The first line contains a single integer \(n\), the number of elements in the array. The second line contains \(n\) space-separated integers representing the array \(a\).

outputFormat

Output the sorted permutation of the given array as a single line of space-separated integers.

## sample
5
1 3 2 3 1
1 1 2 3 3