import sys
n,k=map(int,input().split())
a=[0]*k
i=0
c=0
s=[]
for j in range(n):
    a[int(sys.stdin.readline())%k]+=1
    while i<k:
        if a[i]>c:
            i=i+1
        else:
            break
    if i==k:
        i=0
        if a[i]>c:
            c=c+1
            while a[i]>c:
                i=i+1
    s.append((c*k)+i)
print('\n'.join(map(str,s)))
    