#K39297. Highest Frequency Integer

    ID: 26389 Type: Default 1000ms 256MiB

Highest Frequency Integer

Highest Frequency Integer

You are given a list of integers. Your task is to determine the integer that appears with the highest frequency. In formal terms, let \(f(x)\) be the frequency of integer \(x\). You need to find an integer \(x\) such that \(f(x) = \max_{y}\{f(y)\}\). If there is more than one such integer, choose the smallest one. If the list is empty, output None.

Note: The input is read from standard input and the result should be printed to standard output.

inputFormat

The input consists of two lines:

  • The first line contains an integer \(n\) (where \(n \ge 0\)) representing the number of elements.
  • If \(n > 0\), the second line contains \(n\) space-separated integers.

outputFormat

Print the integer with the highest frequency. In case of a tie, print the smallest integer among them. If the list is empty, print None.

## sample
1
5
5