ll@n,@p,q=1,z=0;int@a[n]; while(q*=p,q<1d9){ HashMaph; h.init(min(q,n),0); rep(i,n){ z+=h[a[i]%q]++; } } wt(z);