#include<bits/stdc++.h>
using namespace std;
#define int long long
void sol(){
    int n;
    cin >> n;
    int a[n], ans = 0;
    map<int, int> m;
    for(int &i:a) cin >> i, m[i]++;
    for(int i = 1; i < 1000001; i++) ans += m[i * i] * m[i * i * i];
    cout << ans << '\n';
    return;
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while(t--){
        sol();
    }
    return 0;
}