A poll collected n ballots; each ballot names one option by its integer id (ids may repeat). Reorder the whole list of n ids so that an id that appears more often comes before an id that appears fewer times. When two ids appear the same number of times, the numerically smaller id comes first. Equal ids naturally end up next to each other.
Input format
Line 1: an integer n.
Line 2: n space-separated integers, the option ids in the order they were collected.
Output format
n space-separated integers on one line: the ids reordered as described above.
Constraints
- 1 ≤ n ≤ 100000
- 1 ≤ id ≤ 1000000000