#K5846. Optimal Array Sequence

    ID: 30647 Type: Default 1000ms 256MiB

Optimal Array Sequence

Optimal Array Sequence

Given an array of positive integers, Alice and Bob take turns removing an element from the array. Both players want to maximize Alice's score. However, after careful analysis it turns out that the best strategy for both players is to remove the largest remaining number. Therefore, the sequence in which the numbers are removed is simply the array sorted in descending order.

Your task is to implement a program that reads the array from standard input and prints the sequence of removals (i.e. the sorted array in descending order) to standard output.

The problem can be mathematically explained as follows: Let \(a_1, a_2, \dots, a_n\) be the elements of the array. The optimal removal order is given by sorting the array such that:

\[ order: a_{i_1} \geq a_{i_2} \geq \dots \geq a_{i_n} \]

inputFormat

Input is taken from standard input (stdin). The input contains two lines. The first line contains one integer \(n\) \( (1 \leq n \leq 10^5)\) representing the number of elements in the array. The second line contains \(n\) space-separated positive integers \(a_1, a_2, \dots, a_n\) \( (1 \leq a_i \leq 10^9)\).

outputFormat

Output the sequence of integers sorted in descending order, separated by a single space, to standard output (stdout).

## sample
5
3 1 4 1 5
5 4 3 1 1