#C3042. Lexicographically Smallest Rope Sequence

    ID: 46426 Type: Default 1000ms 256MiB

Lexicographically Smallest Rope Sequence

Lexicographically Smallest Rope Sequence

You are given a rope comprised of n segments. Each segment has an associated energy value. The rope's overall power is defined as the sum of these energy values:

\( \text{Power} = \sum_{i=1}^{n} s_i \)

To achieve the maximum power, the rope segments can be rearranged in any order, as the sum remains constant. However, among all possible arrangements that yield the maximum power, your task is to find the lexicographically smallest sequence of segments. In this problem, the lexicographically smallest sequence is obtained by sorting the energy values in descending order.

For example, if the rope segments are [3, 3, 1, 2], then the required sequence is [3, 3, 2, 1].

inputFormat

The input is read from stdin and consists of two lines:

  1. The first line contains an integer \( n \) — the number of rope segments.
  2. The second line contains \( n \) space-separated integers, each representing the energy level of a segment.

outputFormat

Print the lexicographically smallest sequence of rope segments (i.e., the sequence sorted in descending order) to stdout. The output should be a single line of \( n \) space-separated integers.

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