#K41. Highest Frequency Number

    ID: 26767 Type: Default 1000ms 256MiB

Highest Frequency Number

Highest Frequency Number

You are given an array of integers. Your task is to find the integer that appears most frequently in the array. If there is more than one such integer, return the smallest one.

Formally, let \( f(x) \) be the frequency of the number \( x \) in the array. You need to find a number \( m \) such that:

[ m = \min { x \mid f(x) = \max_{y} f(y) }. ]

Input Example:

9
3 1 4 4 5 2 2 3 3

Output Example:

3

inputFormat

The input is given from stdin.

The first line contains an integer \( n \) which denotes the number of elements in the array. The second line contains \( n \) space-separated integers.

outputFormat

Print the integer that has the highest frequency in the array. If there are multiple integers with the maximum frequency, print the smallest one.

## sample
9
3 1 4 4 5 2 2 3 3
3

</p>