from heapq import *

q, x = map(int, input().split())
queue, mem, ans, mi = [[0, i] for i in range(x)], [0] * x, [], 0
heapify(queue)

for i in range(q):
    n = int(input())
    cur = n % x
    mem[cur] += 1
    heappush(queue, [mem[cur], cur])

    while queue:
        ele = queue[0]

        if mem[ele[1]] == ele[0]:
            ans.append(str(ele[0] * x + ele[1]))
            break
        else:
            heappop(queue)

print('\n'.join(ans))
