#C13304. Most Frequent Integers

    ID: 42828 Type: Default 1000ms 256MiB

Most Frequent Integers

Most Frequent Integers

You are given a list of integers. Your task is to determine the integer(s) that appear most frequently in the list.

If there is a unique most frequent integer, output that integer. If there is a tie for the highest frequency, output all such integers in ascending order, separated by a single space.

For an empty list, output nothing.

The frequency is defined as the number of times an integer appears in the list. Formally, if the list is \(A = [a_1, a_2, \dots, a_n]\), and for each integer \(x\) we define its frequency as \(f(x)\), then let \(M = \max_{x \in A} f(x)\). The answer is \(\{x \in A \mid f(x) = M\}\). If \(|\{x \mid f(x) = M\}| = 1\) then output that integer, otherwise output all integers (in ascending order) that satisfy the condition.

inputFormat

The input is given via standard input. The first line contains an integer \(n\) denoting the number of elements in the list. The second line contains \(n\) integers separated by spaces. If \(n = 0\), the second line will be empty.

outputFormat

Print the most frequent integer if there is a unique value with maximum frequency; if there is a tie, print all such integers in ascending order, separated by a space. For an empty list, output an empty line.

## sample
6
1 2 2 3 3 3
3

</p>