q,n = map(int,input().split())
levelCount = [0]*n
a =[]
x=0
for _ in range(q):
    levelCount[int(input())%n] += 1
    while levelCount[x%n]:
        levelCount[x%n]-=1
        x+=1
    a.append(x)
print("\n".join(map(str,a)))
    
       