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 p+z==p:
        b[p+z]=1
        while b[p]:
            p+=1
    else:
        z1=z
        while p-z>=0 and b[p-z]==0:
            z+=x
        if p-z>=0:
            b[p-z+x]=1
        else:
            while p+z1>=0 and b[p+z1]:
                z1+=x
            b[p+z1]=1
    stdout.write(str(p)+'\n')
            