import sys
input = sys.stdin.readline
from heapq import *
q,x=map(int,input().split())
a=list(range(0,x))
h=[]
for i in a: heappush(h,i)
out=[]
for _ in range(q):
    n=int(input())
    val=n%x
    a[val]+=x
    heappush(h,a[val])
    z=heappop(h)
    while a[z%x]!=z:
        z=heappop(h)
    out.append(z)
    heappush(h,z)
print('\n'.join(map(str,out)))
    