import sys
input=sys.stdin.buffer.readline



q,x=map(int,input().split())
a=[0 for i in range(x)]
b=[]
for i in range(q):
    n=int(input())
    a[n%x]+=1
    b.append(n)
dict={}
for i in range(x):
    dict[i]=a[i]
 
s=[]
store=0
mini=9999999999
for i in range(x):
    if(a[i]<mini):
        mini=a[i]
        store=i
y=(x*a[store]+store)
pre_i=store
pre_j=a[store]
for i in range(q-1,0,-1):
    dict[b[i]%x]-=1
    if(dict[b[i]%x]==pre_j and b[i]%x<=pre_i):
        pre_i=b[i]%x
        pre_j=dict[b[i]%x]
    elif(dict[b[i]%x]<pre_j):
        pre_i=b[i]%x
        pre_j=dict[b[i]%x]
    s.append(pre_j*x+pre_i)
for i in range(q-2,-1,-1):
    print(s[i])
print(y)