A diagnostic tool emits fault codes. Rebuild the stream so that codes appearing more often come first. Codes with the same frequency are ordered by ascending code value. Within a code's block, the code is simply repeated as many times as it occurred. Print the resulting sequence.
Input format
Line 1: an integer n.
Line 2: n space-separated integers, the fault codes.
Output format
A single line of n space-separated integers: the codes reordered by descending frequency, ties broken by ascending code value, each code repeated according to its count.
Constraints
- 1 <= n <= 40
- 1 <= each fault code <= 1000000