#113Easy
Most frequent number
Time: 1 s · Memory: 256 MB
- Maps and sets
Statement
You are given an array of numbers. Find the number that occurs most often and how many times it occurs. If there are several such numbers, print the smallest of them.
Input format
The first line contains (). The second line contains integers ().
Output format
A single line with two numbers: the most frequent number and its count.
Examples
Input
6 3 1 2 2 2 1
Output
2 3
Input
4 5 1 5 1
Output
1 2
Note
First count all numbers with a dictionary, then walk over it to find the largest counter. On a tie choose the smaller number: in the second example both and occur twice — the answer is 1 2.
