






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


out = []
minn = min(arr)
ind = arr.index(minn)
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:
			minn = arr[n % x]
			ind = arr.index(minn)


for i in out:
	print(i)