import io, os
from sys import stdin






q, x = map(int, stdin.readline().split())
arr = [0]*x
array = []
for _ in range(q):
	n ,= map(int, stdin.readline().split())
	array.append(n)
	arr[n % x] += 1


out = []
minn = arr[0]
ind = 0
for i in range(x):
	if arr[i] < minn:
		minn, ind = arr[i], i

for i in range(q):
	n = array.pop()
	out.append(minn*x + ind)
	arr[n % x] -= 1
	if arr[n % x] <= minn:
		if arr[n % x] == minn:
			if (n % x) < ind:
				ind = n%x

		else:
			ind = n % x
			minn = arr[n % x]



for i in out[::-1]:
	print(i)