Jhakaas and Altered Primes

0

0 votes
Bitmask, Medium, Principle of Inclusion and Exclusion, Number Theory
Problem

Jhakaas, recently being fascinated by prime numbers came up with a problem and asked Apptica to solve it. Apptica is working on Machine Learning Project and passed it to Altaireon to solve.

He is given an array A of N integers and the definition of two functions g and f as follows:


g(i,j)=Number of unique common prime factors between Ai and Aj
f(i,j)=1 if g(i,j)1 otherwise 0

 

You are Altaireon, and now you have to calculate

f(i,j) such that 1i<jN

Input:
First line contains N, size of the array A. Next line contains N space separated positive integers, denoting elements of A.

Output:
Print a single integer, denoting the required answer.

Constraints:
2N3105
1Ai3104

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

f(1,2)=1
f(1,3)=1
f(1,4)=1
f(2,3)=1
f(2,4)=1
f(3,4)=0
So, output=1+1+1+1+1+0=5

Editor Image

?