A logger records n integer readings, which may repeat. Starting from an empty binary search tree, insert the readings in the order given, using this rule: to insert a value x, walk down from the root, going left if x is strictly less than the current node's value, and right if x is greater than or equal to the current node's value, until an empty spot is reached, where a new node is created. Every reading becomes its own node — the tree may therefore contain several nodes with the same value. No rebalancing is performed.
Report the mode: the value that occurs most often among the n readings. If several values are tied for the highest frequency, report the smallest of them.
Input format
Line 1: an integer n.
Line 2: n space-separated integers — the readings, in insertion order (not necessarily distinct).
Output format
A single integer: the mode of the readings.
Constraints
- 1 ≤ n ≤ 40
- -100 ≤ each reading ≤ 100