macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};
use std::collections::{HashSet, HashMap};

fn main() {
    input!{
        n: usize,
        v: [usize; n]
    }
    let ps = primes(100000);
    let ps1: HashSet<usize> = ps.iter().cloned().skip_while(|&x| x * x * x < 10000000000).collect();
    let ps2: HashMap<usize, usize> = ps1.iter().map(|&x| (x * x, x)).collect();
    let mut ans = 0;
    let mut map: HashMap<usize, (Vec<(usize, usize)>, usize, usize)> = HashMap::new();
    let mut ans1 = 0;
    for &s in &v {
        let mut a = s;
        let mut b = s;
        let mut fac = vec![];
        for &p in &ps {
            if p * p * p > 10000000000 {
                break;
            }
            let mut r = 0;
            while a % p == 0 {
                a /= p;
                r += 1;
            }
            b /= p.pow(r as u32 / 3 * 3);
            if r % 3 != 0 {
                fac.push((p, r % 3));
            }
        }
        if b == 1 {
            ans1 = 1;
            continue;
        }
        if let Some(e) = map.get_mut(&b) {
            e.2 += 1;
            continue;
        }
        map.insert(b, (fac, a, 1));
    }
    for val in map.values() {
        let mut a2 = val.0.iter().fold(1, |ac, &(p, r)| ac * p.pow(3 - r as u32));
        if ps1.contains(&val.1) {
            a2 *= val.1 * val.1;
        } else if ps2.contains_key(&val.1) {
            a2 *= *ps2.get(&val.1).unwrap();
        } else if val.1 > 1 {
            ans1 += val.2;
            continue;
        }
        if let Some(&(_, _, c)) = map.get(&a2) {
            ans += max(val.2, c);
        } else {
            ans1 += val.2;
        }
    }
    ans = ans / 2 + ans1;
    println!("{}", ans);
}

fn primes(n: usize) -> Vec<usize> {
    if n < 2 {
        return vec![];
    }
    let mut tab = vec![true; n + 1];
    let mut ps = vec![2];
    for i in 2..n / 2 + 1 {
        tab[i * 2] = false;
    }
    let mut p = 3;
    while p * p <= n {
        if tab[p] {
            ps.push(p);
            for i in 2..n / p + 1 {
                tab[i * p] = false;
            }
        }
        p += 2;
    }
    while p <= n {
        if tab[p] {
            ps.push(p);
        }
        p += 2;
    }
    ps
}


Measured memory_bytes: 21880