Most Frequent Element
Find the value that appears most often in an array.
Input format
The first line has one integer N. The second line has N space-separated integers.
Output format
Print the value that appears the most times. If several values tie for the most, print the smallest of them.
Constraints
- Values fit in a 64-bit signed integer
- Trailing whitespace and a trailing newline are ignored by the judge
Read from stdin, write to stdout. Sample cases below show the exact format.
Sample cases
Example 1
Input
6
1 3 3 2 3 1Expected output
3Example 2
Input
5
4 4 2 2 1Expected output
2