#C13963. Most Frequent Element
Most Frequent Element
Most Frequent Element
You are given a list of integers. Your task is to determine the integer that appears most frequently in the list. In the case of a tie (i.e. multiple integers occur the same maximum number of times), output the smallest integer among them.
Note: The input is guaranteed to have at least one integer.
The frequency calculation can be mathematically expressed as follows: \(\text{Let } f(x) \text{ be the frequency of } x. \) Find \( x \) such that \( f(x) = \max_{y} f(y) \) and if there are multiple such \( x \), choose \( \min\{ x : f(x) = \max_{y} f(y) \} \).
inputFormat
The first line contains an integer \( n \) representing the number of elements in the list. The second line contains \( n \) space-separated integers.
outputFormat
Output a single integer which is the most frequent element in the list. In case of a tie, output the smallest one.
## sample1
1
1