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