from collections import *
# from sortedcontainers import SortedSet, SortedList

q, x = map(int, input().split())
dis, mem, ans, mi = {(0, i) for i in range(x)}, [0] * x, [], 0
# test = SortedList([2, 3, 2])

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

    while mem[mi % x]:
        mem[mi % x] -= 1
        mi += 1
    ans.append(str(mi))

print('\n'.join(ans))
# for i in range(q):
#     n = int(input())
#     cur = n % x
#     dis.discard((mem[cur], cur))
#     mem[cur] += 1
#     dis.add((mem[cur], cur))
#     ele = list(dis)[0]
#     print(ele, dis)
#     ans.append(str(ele[0] * x + ele[1]))
#     dis.add(ele)
#
# print('\n'.join(ans))
