#K49872. Most Frequent Number
Most Frequent Number
Most Frequent Number
You are given a list containing n integers. Your task is to determine the most frequent number in the list. In case of a tie where multiple numbers have the same maximum frequency, you must output the smallest of these numbers.
Formally, let \( f(x) \) be the frequency of the integer \( x \) in the list. You need to find a number \( m \) such that
\[ f(m) = \max_{x} f(x), \]
and if there exists another number \( n \) with \( f(n) = f(m) \), then \( m \le n \).
The input will be read from standard input and the result should be written to standard output.
inputFormat
The first line contains a single integer \( n \) representing the number of elements in the list. The second line contains \( n \) space-separated integers.
Note: You can assume that \( n \geq 1 \).
outputFormat
Output a single integer -- the most frequent number. In case of a tie, output the smallest number among those with the highest frequency.
## sample1
1
1