q, x = [int(i) for i in input().split()]
# d = [0]*x
# mx = -1
for i in range(q):
    d = [0]*x
    mx = -1
    qqq = int(input())
    d[qqq%x]+=1

    while True:
        mm = (mx+1)%x
        if d[mm] >= ((mx+1)//x) + 1:
            mx += 1
        else:
            break
    print(mx+1)

