#K46807. Find the Mode of a List

    ID: 28058 Type: Default 1000ms 256MiB

Find the Mode of a List

Find the Mode of a List

You are given a list of integers. Your task is to find the mode of the list. The mode is the integer that appears most frequently. In case of a tie (i.e. more than one integer appears with the same maximum frequency), you must output the smallest integer among them.

Let \( n \) be the number of integers in the list, and let the list be \( a_1, a_2, \ldots, a_n \). You need to determine the integer \( m \) such that:

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

where \( f(x) \) is the frequency of the integer \( x \) in the list.

inputFormat

The input is read from standard input (stdin) and consists of two lines:

  1. The first line contains a single integer \( n \) representing the number of elements in the list.
  2. The second line contains \( n \) space-separated integers.

outputFormat

Output a single line to standard output (stdout) with one integer: the mode of the list as specified above.

## sample
1
10
10