Max Frequency Element

Given an array of integers, find the element with the highest frequency. If multiple elements have the same frequency, return the smallest one.

Input Format

Integer n (number of elements)

n space-separated integers

Output Format

Integer (element with highest frequency)

Sample Input

6
1 3 1 3 2 1

Sample Output

1

Try Your Code

← Back to Problems List