Jerry has found a playlist with songs! He decides to listen to each one and rate it on a scale from
to
. He now wants to know the most frequent rating given to the songs in this playlist. If there are two ratings with the same frequency, he will choose the lower rating. Because there are a lot of songs in this playlist, can you help him find out what the most frequent rating is?
Input Specification
The first line will contain an integer
, the number of songs in this playlist.
The next line will contain
integers, each between
to
, inclusive, which is the rating that he gave that song.
Output Specification
Print out the rating that has the highest frequency, or the lowest rating if there is more than one rating with the highest.
Sample Input 1
6
5 3 2 5 4 1
Sample Output 1
5
Sample Explanation 1
Out of the total songs in the playlist, a rating of
was given to
songs, while the rest of the ratings were only given to
song each, so
is the most frequent rating given by Jerry in this playlist.
Sample Input 2
10
1 5 3 3 2 4 3 1 2 1
Sample Output 2
1
Sample Explanation 2
The most frequent ratings in this playlist are and
, both given to
songs each by Jerry. The answer is
since he will choose the lower rating if the highest frequency exists for multiple ratings.
Comments