cho.sh
Notes
Loading...

Coprime Products from Six Indices

Time limit

2s

Memory limit

512 MB

Problem

You are given NNN integers X1,X2,…,XNX_1, X_2, \dots, X_NX1​,X2​,…,XN​. For each ordered pair (i,j)(i, j)(i,j), define Yi,j=Xi×Xj mod 359999Y_{i,j} = X_i \times X_j \bmod 359999Yi,j​=Xi​×Xj​mod359999.

Count the number of ordered 6-tuples (a,b,c,d,e,f)(a, b, c, d, e, f)(a,b,c,d,e,f) that satisfy all of the following conditions.

  • 1≤a,b,c,d,e,f≤N1 \le a, b, c, d, e, f \le N1≤a,b,c,d,e,f≤N
  • gcd⁡(Ya,b,Yc,d,Ye,f)=1\gcd(Y_{a,b}, Y_{c,d}, Y_{e,f}) = 1gcd(Ya,b​,Yc,d​,Ye,f​)=1

Use gcd⁡(0,0)=0\gcd(0, 0) = 0gcd(0,0)=0 in this definition.

Input

The first line contains the integer NNN.

The second line contains X1,X2,…,XNX_1, X_2, \dots, X_NX1​,X2​,…,XN​, separated by spaces.

Output

Print the number of ordered 6-tuples satisfying the condition, modulo 109+710^9 + 7109+7.

Constraints

  • 1≤N≤1061 \le N \le 10^61≤N≤106
  • 1≤Xj≤1061 \le X_j \le 10^61≤Xj​≤106