import
java.util.*;
public
class
GFG
{
public
static
HashMap<Integer, Integer>
countMap(ArrayList<Integer> v)
{
HashMap<Integer, Integer> map
=
new
HashMap<Integer, Integer>();
for
(
int
i =
0
; i < v.size(); i++) {
if
(map.containsKey(v.get(i))) {
map.put(v.get(i), map.get(v.get(i)) +
1
);
}
else
{
map.put(v.get(i),
1
);
}
}
return
map;
}
public
static
int
totalFactors(HashMap<Integer, Integer> m1,
HashMap<Integer, Integer> m2)
{
for
(Map.Entry it : m2.entrySet()) {
int
key = (
int
)it.getKey();
int
value = (
int
)it.getValue();
if
(m1.containsKey(key)) {
m1.put(key, m1.get(key) + value);
}
else
{
m1.put(key, value);
}
}
int
product =
1
;
for
(Map.Entry it : m1.entrySet()) {
product *= ((
int
)it.getValue() +
1
);
}
return
product;
}
public
static
HashMap<Integer, Integer>
primeFactorize(
int
n)
{
ArrayList<Integer> pfac =
new
ArrayList<Integer>();
int
temp =
2
;
while
(temp * temp <= n) {
if
(n % temp ==
0
) {
pfac.add(temp);
n = n / temp;
}
else
{
temp++;
}
}
if
(n >
1
) {
pfac.add(n);
}
return
countMap(pfac);
}
public
static
int
maxProduct(
int
[] arr,
int
n)
{
ArrayList<HashMap<Integer, Integer> > vum
=
new
ArrayList<HashMap<Integer, Integer> >();
for
(
int
i =
0
; i < n; i++) {
vum.add(primeFactorize(arr[i]));
}
int
maxp =
0
;
for
(
int
i =
0
; i < n; i++) {
for
(
int
j =
0
; j < n; j++) {
if
(i == j) {
continue
;
}
maxp = Math.max(
maxp,
totalFactors(vum.get(i), vum.get(j)));
}
}
return
maxp%
10
;
}
public
static
void
main(String[] args)
{
int
[] arr = {
4
,
3
,
8
};
System.out.print(maxProduct(arr,
3
));
}
}