398 传统题

[ABC342D] 完全平方乘积对 (Square Pair)

时间限制
2000ms
内存限制
1024MiB
登顶 / 尝试
0/ 0
难度
4
    上传者 标签AtCoderABC342普及+数论质因数分解

[ABC342D] 完全平方乘积对 (Square Pair)

Score: 400400 points

Problem Statement

You are given a sequence of non-negative integers A=(A1,…,AN)A=(A_1,\ldots,A_N) of length NN. Find the number of pairs of integers (i,j)(i,j) that satisfy both of the following conditions:

  • 1≤i<j≤N1\leq i < j\leq N

  • AiAjA_i A_j is a square number.

Here, a non-negative integer aa is called a square number when it can be expressed as a=d2a=d^2 using some non-negative integer dd.

Constraints

  • All inputs are integers.

  • 2≤N≤2×1052\leq N\leq 2\times 10^5

  • 0≤Ai≤2×1050\leq A_i\leq 2\times 10^5

Input

The input is given from Standard Input in the following format:

$N$
$A_1$ $\ldots$ $A_N$

Output

Print the answer.

Sample Input 1

5
0 3 2 8 12

Sample Output 1

6

Six pairs of integers, (i,j)=(1,2),(1,3),(1,4),(1,5),(2,5),(3,4)(i,j)=(1,2),(1,3),(1,4),(1,5),(2,5),(3,4), satisfy the conditions.

For example, A2A5=36A_2A_5=36, and 3636 is a square number, so the pair (i,j)=(2,5)(i,j)=(2,5) satisfies the conditions.

Sample Input 2

8
2 2 4 6 3 100 100 25

Sample Output 2

7