import math
q,x=map(int,input().split())
#a=[0 for i in range(x)]
m=2**math.ceil(math.log2(x))
b=[[0,0] for i in range(2*m-1)]
for i in range(m-1,2*m-1):
    b[i][1]=i-m+1
    if (i-m+1)>=x:
        b[i][0]=999999
for i in range(m-2,-1,-1):
    if b[i*2+1][0]<=b[i*2+2][0]:
        b[i]=b[i*2+1]
    else:
        b[i]=b[i*2+2]
ma,mai=0,0
ans=[]
for i in range(q):
    y=int(input())%x
    #a[y]+=1
    b[m-1+y][0]+=1
    #print(b,y)
    if y==b[0][1]:
        i=m-1+y
        while i!=0:
            #print(i,i,i,i,i)
            ni=(i-1)//2
            #print(b[ni*2+1],b[ni*2+2],ni*2+1,ni*2+2,ni)
            if b[ni*2+1][0]<=b[ni*2+2][0]:
                b[ni]=b[ni*2+1]
            else:
                b[ni]=b[ni*2+2]
            i=ni
            #print(b,i,i)
            
        ma=b[0][0]
    ans.append(ma*x+b[0][1])
print('\n'.join(map(str,ans)))
