#C12250. Most Frequent Elements

    ID: 41657 Type: Default 1000ms 256MiB

Most Frequent Elements

Most Frequent Elements

Given an array of integers, your task is to find all the elements that have the highest frequency. Formally, let \(f(x)\) denote the number of times element \(x\) occurs in the array. You need to output all elements \(x\) such that \(f(x) = \max_{y \in A} f(y)\), where \(A\) is the input array. If several elements share the highest frequency, output them in ascending order. In the case of an empty array, output nothing.

Input Example: For an input of 9 followed by 1 3 2 2 3 4 5 2 3, the elements 2 and 3 both appear most frequently, so the output should be 2 3.

inputFormat

The first line of input contains a non-negative integer (n) indicating the number of elements. If (n > 0), the second line contains (n) space-separated integers.

outputFormat

Output the integer(s) that appear most frequently in the list, in ascending order. If the array is empty, output nothing.## sample

9
1 3 2 2 3 4 5 2 3
2 3