#C11720. Find the Winner

    ID: 41068 Type: Default 1000ms 256MiB

Find the Winner

Find the Winner

You are given an array of integers. The winning number is defined as the one that appears most frequently in the array. In case of a tie, the smallest number among those with the highest frequency is chosen.

In mathematical terms, if the frequency of an integer \( x \) in the array is denoted as \( f(x) \), then the winning number \( W \) is determined by:

\( W = \min\{ x \mid f(x) = \max_{y} f(y) \} \)

Your task is to determine the winning number given the input array.

inputFormat

The first line contains an integer \( n \), representing the number of elements in the array.

The second line contains \( n \) space-separated integers.

outputFormat

Output the winning number that satisfies the conditions described above.

## sample
6
1 2 2 3 3 3
3

</p>