import
java.util.*;
class
GFG{
static
int
countFreq(
int
arr[],
int
n)
{
HashMap<Integer,
Integer> mp1 =
new
HashMap<Integer,
Integer>();
for
(
int
i =
0
; i < n; ++i)
{
if
(mp1.containsKey(arr[i]))
{
mp1.put(arr[i], mp1.get(arr[i]) +
1
);
}
else
{
mp1.put(arr[i],
1
);
}
}
HashMap<Integer,
Integer> mp2 =
new
HashMap<Integer,
Integer>();
for
(Map.Entry<Integer,
Integer> it : mp1.entrySet())
{
if
(mp2.containsKey(it.getValue()))
{
mp2.put(it.getValue(),
mp2.get(it.getValue()) +
1
);
}
else
{
mp2.put(it.getValue(),
1
);
}
}
int
M = Integer.MIN_VALUE;
for
(Map.Entry<Integer,
Integer> it : mp2.entrySet())
{
M = Math.max(M, it.getValue());
}
for
(Map.Entry<Integer,
Integer> it : mp2.entrySet())
{
if
(M == it.getValue())
{
return
it.getKey();
}
}
return
0
;
}
public
static
void
main(String[] args)
{
int
arr[] = {
6
,
10
,
3
,
10
,
8
,
3
,
6
,
4
};
int
n = arr.length;
System.out.print(countFreq(arr, n));
}
}