import sys
from collections import defaultdict

inp = sys.stdin.readline
ans = ""

mex = 0

sett = set()
dic = defaultdict(int)

q, x = map(int, inp().split())

for _ in range(q):
	n = int(inp())
	if n == mex:
		sett.add(n)
		while (mex in sett):
			mex += 1
		dic[n%x] += 1
		sett.add(mex)

	else:
		dic[n%x] += 1
		sett.add(n)

	while dic[mex%x] > 1:
		dic[mex%x] -= 1
		mex += 1
		sett.add(mex)

	ans += str(mex) + "\n"
print("\n\n"+ans)

