n,k=map(int,input().split())
a=[0]*k
i=0
c=0
for j in range(n):
    p=int(input())
    a[p%k]+=1
    while i<k:
        if a[i]>c:
            i=i+1
        else:
            break
    if i==k:
        i=0
        while i<k and a[i]>c:
            i=i+1
        c=c+1
    print((c*k)+i)
