#K58602. Finding Modes of a List
Finding Modes of a List
Finding Modes of a List
You are given a list of \( n \) integers. Your task is to find the mode(s) of the list; that is, the integer(s) that occur most frequently. Formally, for each integer \( x \) in the list, let \( f(x) \) denote its frequency. Let \( m = \max_{x} f(x) \). You should output all integers \( x \) such that \( f(x) = m \) in ascending order.
Note: If all numbers appear with the same frequency, then every number is considered a mode.
inputFormat
The input consists of two lines:
- The first line contains a single integer \( n \) (\( 1 \leq n \leq 10^5 \)), which is the number of integers in the list.
- The second line contains \( n \) space-separated integers. Each integer is in the range \( [-10^9, 10^9] \).
outputFormat
Print the mode(s) (the most frequent integer(s)) in ascending order, separated by a single space.
## sample10
1 2 2 3 3 4 4 4 5 6
4
</p>