Problem:
Score : 1100 points

Problem Statement

Snuke got positive integers s_1,...,s_N from his mother, as a birthday present. There may be duplicate elements.

He will circle some of these N integers. Since he dislikes cubic numbers, he wants to ensure that if both s_i and s_j (i ≠ j) are circled, the product s_is_j is not cubic. For example, when s_1=1,s_2=1,s_3=2,s_4=4, it is not possible to circle both s_1 and s_2 at the same time. It is not possible to circle both s_3 and s_4 at the same time, either.

Find the maximum number of integers that Snuke can circle.

Constraints

1 ≦ N ≦ 10^5

1 ≦ s_i ≦ 10^{10}

All input values are integers.

Input

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

N
s_1
:
s_N

Output

Print the maximum number of integers that Snuke can circle.

Sample Input 1

8
1
2
3
4
5
6
7
8

Sample Output 1

6

Snuke can circle 1,2,3,5,6,7.

Sample Input 2

6
2
4
8
16
32
64

Sample Output 2

3

Sample Input 3

10
1
10
100
1000000007
10000000000
1000000009
999999999
999
999
999

Sample Output 3

9

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include<cassert>
#include<cmath>
#include<map>
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(s...)  fprintf(stderr, s)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }

const int MAX = 10000000;
int min_factor[MAX+1];
vector<int>prime;
void make_prime() {
    for (int i=2; i<=MAX; i+=2) min_factor[i] = 2;
    for (int i=3; i<=MAX; i+=3) if (!min_factor[i]) min_factor[i] = 3;
    for (int i=5, d=2; i*i<=MAX; ) {
	if (!min_factor[i]) {
	    min_factor[i] = i;
	    for (int j=i*i; j<=MAX; j+=i)
		if (!min_factor[j]) min_factor[j] = i;
	}
	i += d; d = 6 - d;
    }
    for (int i=2; i<=MAX; i++) {
	if (min_factor[i]==0) min_factor[i] = i;
	if (min_factor[i]==i) prime.push_back(i);
    }
}

LL is_sq(LL x) {
    LL y = sqrt(x);

    if (y) y--;
    while (y*y < x) y++;
    if (y*y == x) return y;
    else return 0;
}

int N;
LL S[100111];
LL T[100111], U[100111];
map<LL, LL> mp, inv;

LL safe_mul(LL x, LL y) {
    if (x < 0 || y < 0) return -1;
    if ((double)x * (double)y > 1e15) return -1;
    return x * y;
}


int main() {
    make_prime();


    scanf("%d", &N);
    REP (i, N) scanf("%lld", S+i);

    REP (i, N) {
	T[i] = 1;
	U[i] = 1;
	for (int p=0; ; p++) {
	    LL t = (LL)prime[p] * prime[p] * prime[p];
	    if (t > S[i]) break;
	    int c = 0;
	    while (S[i] % prime[p] == 0) {
		S[i] /= prime[p];
		c++;
	    }

	    c %= 3;
	    REP (j, c) T[i] *= prime[p];
	    REP (j, (3-c)%3) U[i] = safe_mul(U[i], prime[p]);
	}

	if (LL p = is_sq(S[i])) {
	    U[i] = safe_mul(U[i], p);
	} else {
	    U[i] = safe_mul(safe_mul(U[i], S[i]), S[i]);
	}
	T[i] *= S[i];
	if (U[i] != -1) inv[T[i]] = U[i];
	mp[T[i]]++; 
//	eprintf("%lld %lld %lld\n", S[i], T[i], U[i]);
    }

    int ans = 0;
    EACH (e, mp) {
	if (e->first == 1) {
	    ans++;
	} else if (inv.count(e->first)) {
	    LL x = inv[e->first];
	    if (mp.count(x)) {
		if (e->first < x) {
		    int y = mp[x];
		    assert(y);
		    ans += max(e->second, (LL)y);
		}
	    } else {
		ans += e->second;
	    }
	} else {
	    ans += e->second;
	}
    }

    printf("%d\n", ans);

    return 0;
}