#C5020. City Runner Prioritization

    ID: 48624 Type: Default 1000ms 256MiB

City Runner Prioritization

City Runner Prioritization

In this problem, you are provided with a list of runners along with their respective city IDs. Your task is to count the number of runners from each city and sort the city IDs based on the following criteria:

  1. Cities with a higher number of runners should come first.
  2. If two or more cities have the same number of runners, they should be sorted in ascending order.

The final result should be output as a space-separated list of city IDs on a single line.

inputFormat

The first line of input contains an integer n representing the number of runners. The second line contains n space-separated integers where each integer represents a city ID.

outputFormat

Output the sorted list of city IDs in one line, where the cities are ordered by the number of runners in descending order, and in the case of a tie, by their city IDs in ascending order. The city IDs must be separated by a single space.## sample

5
2 3 2 3 1
2 3 1

</p>