#K67087. Most Frequent Element
Most Frequent Element
Most Frequent Element
You are given a list of integers and your task is to find the element that occurs most frequently. In case of a tie (i.e. multiple elements have the same highest frequency), return the smallest element among them.
Let \( n \) denote the number of integers in the list. Note that the list may include negative numbers as well.
Example: For the list [1, 3, 3, 3, 2, 1, 2], the element 3 occurs most frequently, therefore the output should be 3.
inputFormat
The input is provided from standard input (stdin) in the following format:
- The first line contains an integer \( n \) representing the total number of elements in the list.
- The second line contains \( n \) space-separated integers.
outputFormat
Output a single integer to standard output (stdout) which is the most frequent element in the list. If there is more than one candidate, output the smallest among them.
## sample1
7
7