from collections import * N, B = map(int, input().split()) A = list(map(int, input().split())) S = set() ans1 = pow(2, N, B) nokori = N for i, a in enumerate(A): if a in S: print(ans1) else: nokori -= 1 print( (pow(2, i + 1, B) - 1) * pow(2, nokori, B) % B ) S.add(a)