int n; cin>>n;
long val;
map<int,long> mp3;
long long res=0;
while(n--){
cin>>val;
if(mp3.count(val)) res+=mp3[val];
//mp3.count(val) returns 1 if val is present in the map already or
//the number of times the key K is present in the map container.
if(mp2.count(val)) mp3[val*r]+=mp2[val];
mp2[val*r]++;
}
cout<<res<<endl;