IntermediateRating 1200
Sort by Frequency
Sort the numbers by how often they appear (most frequent first); equal frequencies by smaller value first. Print the sorted list.
Input
n, then n integers.
Output
One line.
Sample 1
Input
9 2 5 2 8 5 6 8 8 1
Output
8 8 8 2 2 5 5 1 6
Sample 2
Input
1 4
Output
4
Output appears here