import sys input = sys.stdin.readline n, m, b = map(int, input().split()) A = list(map(int, input().split())) ans = 1 for i in range(n): a = A[i] ans *= (1 + pow(m, a, b)) % b ans %= b print(ans)