N, M, B = map(int, input().split())
A = list(map(int, input().split()))

ans = 1
for x in A:
    ans *= 1 + pow(M, x, B)
    ans %= B
print(ans)