#K1611. Most Frequent Element

    ID: 24506 Type: Default 1000ms 256MiB

Most Frequent Element

Most Frequent Element

Given a list of n integers, find the integer that appears most frequently. In case there are multiple integers with the same highest frequency, output the smallest one among them.

Note: You can assume that n > 0.

The problem requires you to read from standard input and write the result to standard output.

The solution should be implemented in a way that it can handle different edge cases such as a list with a single element or a list where all elements are distinct.

inputFormat

The first line contains an integer n representing the number of elements in the list (n > 0).

The second line contains n space-separated integers, which can be negative, zero, or positive.

outputFormat

Print a single integer: the number that occurs most frequently in the list. If there are multiple such numbers, output the smallest one.

## sample
1
5
5