#C8487. Most Frequent Element
Most Frequent Element
Most Frequent Element
Given a list of integers, your task is to find the most frequent element. In other words, if the frequency of an element \(x\) is defined as \(f(x)\), you need to find the element \(x\) such that \(f(x)\) is maximized. In case there is a tie (i.e. more than one element with the maximum frequency), output the smallest such element.
The input is provided in two lines: the first line contains a single integer \(n\) representing the number of elements, and the second line contains \(n\) integers separated by spaces. Your program should print the resulting element to standard output.
inputFormat
The first line contains an integer \(n\) \((1 \leq n \leq 10^5)\), the number of elements in the list. The second line contains \(n\) integers \(a_1, a_2, \ldots, a_n\) where each \(a_i\) satisfies \(|a_i| \leq 10^9\).
outputFormat
Print a single integer, which is the most frequent element in the list. If multiple elements have the same frequency, print the smallest one.
## sample1
5
5