def mex(x, query):
    lst, result = [0] * x, 0
    lst[query % x] += 1
    while lst[result % x] != 0:
        lst[result % x] -= 1
        result += 1
    return result


q, X = [int(i) for i in input().split()]
for _ in range(q):
    a = int(input())
    print(mex(X, a))