#K57467. Minimize Disorderliness

    ID: 30427 Type: Default 1000ms 256MiB

Minimize Disorderliness

Minimize Disorderliness

You are given N books arranged in a random order. Your task is to rearrange them in ascending order to minimize their disorderliness. In other words, you need to sort the list of books by their numerical values.

Note: The level of disorderliness is minimized when the list is sorted in ascending order. This can be viewed mathematically as minimizing the differences between adjacent book numbers, i.e., \( \min \sum_{i=1}^{N-1} |a_{i+1} - a_i| \), where the optimal configuration is the sorted order.

inputFormat

The input is given via standard input and consists of two lines:

  • The first line contains a single integer \(N\) denoting the number of books.
  • The second line contains \(N\) space-separated integers representing the initial arrangement of the books.

outputFormat

Print the sorted order of the books as space-separated integers on one line. The output should be written to standard output.

## sample
3
3 1 2
1 2 3