#include using namespace std; long long repeat2(long long a, long long b,long long mod){ long long p = a%mod,ret = 1; while(b){ if(b&1) ret = ret*p %mod; p = p*p %mod; b >>= 1; } return ret; } int main() { int N,P,Q; cin >> N >> P >> Q; vector A(N); for(auto &a : A) cin >> a; sort(A.begin(),A.end()); vector> Rmod(N); vector add(100000); for(int i=N-1; i>=0; i--) add.at(repeat2(5,A.at(i),P))++,Rmod.at(i) = add; long long answer = 0; for(int i=0; i