N,M,B=map(int,input().split()) As = list(map(int, input().split())) ans=1 for a in As: ans*=(1+pow(M,a,B))%B ans%=B print(ans)