n, b = map(int, input().split()) a = list(map(int, input().split())) s = set() p = pow(2, n, b) for i in a: if i in s: print(p) else: s.add(i) print((p - pow(2, n - len(s), b)) % b)