import sys
def minp():
    return sys.stdin.readline().strip()
def mint():
    return int(minp()) 
def mints():
    return map(int, minp().split())
n,m = mints()
rem=[0]*(m)
mex=0
for i in range(n):
    q=mint()
    rem[q%m]+=1
    while rem[mex%m]>0:
        rem[mex%m]-=1
        mex+=1
    print(mex)                 