ai = (p^2)*k1; aj = (q^2)*k2;
当且仅当k1 == k2时 ai*aj为完全平方数
#include"cstdio"
#include"cstring"
#include"iostream"
#include"algorithm"
using namespace std;
typedef long long LL;
const int maxn = 1e6+100;
bool is_prime[maxn];
int prime[maxn],tot,x,cnt[maxn],id[maxn];
void get_prime()
{
int n = 1e6+99;
for(int i = 2; i <= n; i++){
if(!is_prime[i]) prime[++tot] = i;
for(int j = 1; j <= tot; j++){
if(i*prime[j] > n) break;
is_prime[i*prime[j]] = 1;
if(i%prime[j] == 0) break;
}
}
for(int i = 1; prime[i-1] <= n; i++){
prime[i]*=prime[i];
}
for(int i = 1; i <= n; i++){
int x = i;
for(int j = 1; prime[j] <= x; j++){
while(x%prime[j] == 0)
x /= prime[j];
}
id[i] = x;
}
}
int main()
{
#ifdef __LOCAL__
freopen("input.txt","r",stdin);
#endif // __LOCAL
int n;
get_prime();
while(~scanf("%d",&n)){
int maxx = 0;
for(int i = 1,x; i <= n; i++){
scanf("%d",&x);
maxx = max(maxx,id[x]);
cnt[id[x]]++;
}
LL ans = 0;
for(int i = 0; i <= maxx; i++){
ans += (LL) cnt[i]*(cnt[i]-1)/2;
cnt[i] = 0;
}
cout<<ans<<endl;
}
return 0;
}