#K65852. Mode of Daily Read Counts
Mode of Daily Read Counts
Mode of Daily Read Counts
You are given a library containing (n) books. Each book has a daily read count represented by an integer. Your task is to determine the mode of these read counts. The mode is defined as the number which appears most frequently. In case there is more than one such number, choose the smallest one. That is, if the set of numbers (a_1, a_2, \dots, a_n) has multiple candidates with the same maximum frequency, you must output (\min{a_i : \text{frequency}(a_i) = f_{\max}}).
Input/Output Format Change: All inputs are read from stdin and all outputs must be written to stdout.
inputFormat
The first line of input contains an integer (n) representing the number of books. The second line contains (n) space-separated integers denoting the daily read counts for each book.
outputFormat
Print a single integer — the mode of the read counts. If there are multiple modes, output the smallest value among them.## sample
5
3 3 2 2 2
2
</p>