import sys
input = sys.stdin.buffer.readline

Q, X = map(int, input().split())
A = [0]*X

def segfunc(x, y):
    if x[0] < y[0]:
        return x
    elif x[0] == y[0]:
        if x[1] <= y[1]:
            return x
        else:
            return y
    else:
        return y

def init(init_val):
    # set_val
    for i in range(X):
        seg[i+num-1] = [init_val[i], i]
    # built
    for i in range(num-2, -1, -1):
        seg[i] = segfunc(seg[2*i+1], seg[2*i+2])

def update(k, x):
    k += num - 1
    seg[k][0] += x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[2*k+1], seg[2*k+2])

def query(p, q):
    if q <= p:
        return ide_ele
    p += num - 1
    q += num - 2
    res = [ide_ele, X]
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res, seg[p])
        if q&1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res, seg[p])
    else:
        res = segfunc(segfunc(res, seg[p]), seg[q])
    return res

# identity element
ide_ele = 10**18

num = 2**(X-1).bit_length()
seg = [[ide_ele, X] for _ in range(2*num)]

init(A)

for i in range(Q):
    y = int(input())
    y %= X
    update(y, 1)
    c, idx = query(0, X)
    print(c*X+idx)
