from collections import defaultdict as dd
from sys import stdin,stdout
input=stdin.readline
q,x=map(int,input().split())
a=[]
b=[0]*10**6
p=0
for _ in range(q):
    i=int(input())
    z=abs(i-p)%x
    if i==p:
        b[p]=1
        while b[p]:
            p+=1
    elif i>p:
        k=i-((i-p)//x)*x
        b[k]=1
        while b[p]:
            p+=1
    else:
        k=i-(-(p-i)//x)*x
        b[k]=1
        while b[p]:
            p+=1
    stdout.write(str(p)+'\n')
            