import
java.util.*;
class
GFG
{
static
int
MAX =
100001
;
static
int
ROW =
10
;
static
int
COl =
3
;
static
Vector<Integer> []indices =
new
Vector[MAX];
static
int
test[][] = { {
2
,
3
,
6
}, {
2
,
4
,
4
},
{
2
,
6
,
3
}, {
3
,
2
,
6
},
{
3
,
3
,
3
}, {
3
,
6
,
2
},
{
4
,
2
,
4
}, {
4
,
4
,
2
},
{
6
,
2
,
3
}, {
6
,
3
,
2
} };
static
int
find_triplet(
int
array[],
int
n)
{
int
answer =
0
;
for
(
int
i =
0
; i < MAX; i++)
{
indices[i] =
new
Vector<>();
}
for
(
int
i =
0
; i < n; i++)
{
indices[array[i]].add(i);
}
for
(
int
i =
0
; i < n; i++)
{
int
y = array[i];
for
(
int
j =
0
; j < ROW; j++)
{
int
s = test[j][
1
] * y;
if
(s % test[j][
0
] !=
0
)
continue
;
if
(s % test[j][
2
] !=
0
)
continue
;
int
x = s / test[j][
0
];
int
z = s / test[j][
2
];
if
(x > MAX || z > MAX)
continue
;
int
l =
0
;
int
r = indices[x].size() -
1
;
int
first = -
1
;
while
(l <= r)
{
int
m = (l + r) /
2
;
if
(indices[x].get(m) < i)
{
first = m;
l = m +
1
;
}
else
{
r = m -
1
;
}
}
l =
0
;
r = indices[z].size() -
1
;
int
third = -
1
;
while
(l <= r)
{
int
m = (l + r) /
2
;
if
(indices[z].get(m) > i)
{
third = m;
r = m -
1
;
}
else
{
l = m +
1
;
}
}
if
(first != -
1
&& third != -
1
)
{
answer += (first +
1
) * (indices[z].size() - third);
}
}
}
return
answer;
}
public
static
void
main(String []args)
{
int
array[] = {
2
,
4
,
5
,
6
,
7
};
int
n = array.length;
System.out.println(find_triplet(array, n));
}
}