l,k=map(int,input().split())
lis=[0]*k
i=0
A=[]
for z in range(l):
    
    
    lis[int(input())%k]+=1
    while(lis[i%k]):    
        lis[i%k]-=1 
        i=i+1
    A.append(i)
print("\n".join(map(str,A)))