l = [int(x) for x in input().split()]

q = l[0]
x = l[1]

mex = [0 for i in range(x)]
nlist = [{mex[i]:i} for i in range(x)]

for i in range(q):
    aux = int(input()) % x
    nlist.remove({mex[aux]:aux})
    mex[aux]+=1
    nlist.append({mex[aux]:aux})
    nlist.sort(key = lambda val : x*list(val.keys())[0] + list(val.values())[0])
    print(x*list(nlist[0].keys())[0]+list(nlist[0].values())[0])

#print(mex)
print(nlist)