import sys
def get():
    global x, now_min
    res = [0, 1000000000]#index, count
    token = 0
    for i in range(x):
        c=list_cycle[i]
        if c==now_min:
            res = [i, c]
            token = 1
            break
        if c<res[1]:
            res = [i, c]
    if not token:
        now_min+=1
    return res[1]*x + res[0]



q, x= map(int, sys.stdin.readline().split())
list_cycle=[0 for _ in range(x)]
now_min, pointer = 0, 0
for i in range(q):
    now = int(sys.stdin.readline())
    list_cycle[now%x]+=1
    #--------------------------------------
    while list_cycle[pointer%x] > pointer//x:
        pointer+=1
    #--------------------------------------
    print(pointer)
    #print(get())
