#C4734. Most Frequent Fruit Count

    ID: 48305 Type: Default 1000ms 256MiB

Most Frequent Fruit Count

Most Frequent Fruit Count

You are given an integer T representing the number of trees, and a sequence of T integers representing the fruit counts produced by each tree type. Your task is to determine the fruit count of the tree type that appears most frequently. If there is a tie in the frequency, choose the tree type with the smallest fruit count.

Formally, let \( f(x) \) denote the frequency of a tree type producing \( x \) fruits. You need to find the value \( x \) such that:

[ x = \min{ y \mid f(y) = \max_{z} f(z) }. ]

Input is read from stdin and output is printed to stdout.

inputFormat

The first line contains an integer T (the number of trees). The second line contains T space-separated integers representing the fruit counts for each tree type.

outputFormat

Output a single integer — the fruit count of the tree type that occurs most frequently. In case of a tie, output the smallest fruit count among those.

## sample
7
3 1 2 1 2 3 3
3

</p>