querie, x = map(int, input().split())
queries = []
used = [0] * x
mex = 0

for number in range(querie):
    element = int(input())
    used[element % x] += 1
    queries.append(element)

minimum = used[0]
index = 0

for value in range(x):
    if used[value] < minimum and minimum:
        minimum = used[value]
        index = value

answer = [minimum * x + index]
#print(f'queries : {queries}')
    
for value in queries[-1::- 1]:
#    print(f'used : {used}')
#    print(f'value % x : {value % x}')
#    print(f'minimum : {minimum}')
#    print(f'index : {index}')
#    print(f'value : {value}')
#    used[value % x] -= 1
    if (used[value % x] == minimum  and value % x < index) or used[value % x] < minimum:
        minimum = used[value % x]
        index = value % x
        answer.insert(0, minimum * x + index)
    else:
        answer.insert(0, answer[0])
del answer[0]
for i in answer:
    print(i)

