n,m,b = map(int,input().split()) a = list(map(int,input().split())) r = [pow(m, a[i], b) for i in range(n)] t = 1 ans = 0 for i in range(n): t *= r[i] + 1 t %= b print(t)