#P2714. 四元组统计

四元组统计

Description

There are nn positive integers aia _ i. You need to count how many quadruples satisfy gcd(ai,aj,ak,al)=1\gcd(a _ i, a _ j, a _ k, a _ l) = 1.

Input Format

The input contains multiple testdata sets. For each testdata set: the first line contains a positive integer nn, followed by one line with nn positive integers aia _ i.

Output Format

Several lines, each corresponding to one testdata set, representing the number of quadruples that satisfy the requirement.

4
2 3 4 5
4
2 4 6 8
7
2 3 4 5 7 6 8  
1
0
34

Hint

For 30%30\% of the testdata, 4n104 \le n \le 10, and the number of testdata sets does not exceed 1010.

For 100%100\% of the testdata, 4n100004 \le n \le 10000, 1ai100001 \le a _ i \le 10000, and the number of testdata sets does not exceed 100100.

Translated by ChatGPT 5