#K78152. Sort Heights of Students

    ID: 35023 Type: Default 1000ms 256MiB

Sort Heights of Students

Sort Heights of Students

You are given the heights of n students, and your task is to sort these heights in descending order such that the tallest student comes first and the shortest last. In addition, if two or more students share the same height, their relative order in the original input should be preserved.

This is essentially a stable sort in descending order. You might find it useful to consider sorting algorithms that maintain original order for equal elements. In mathematical terms, given an array \( h = [h_1, h_2, \dots, h_n] \), you must transform it into an array \( h' \) such that \[ h'_1 \ge h'_2 \ge \dots \ge h'_n, \] while if \( h_i = h_j \) and \( i < j \), then the order of these elements in \( h' \) remains the same as in \( h \).

inputFormat

The input is read from standard input (stdin). The first line contains a single integer n representing the number of students. The second line contains n space-separated integers representing the heights of the students.

outputFormat

Output the sorted heights in a single line separated by a single space. The output should be written to standard output (stdout).

## sample
6
160 180 165 170 165 160
180 170 165 165 160 160