from heapq import *
import sys

if __name__ == '__main__':
    q, n = [int(__) for __ in input().strip().split()]
    input = sys.stdin.readline
    arr = list(range(n))
    heap = []
    op = []
    for x in arr:
        heappush(heap, x)
    for _ in range(q):
        inp = int(input()) % n
        arr[inp] += n
        heappush(heap, arr[inp])

        sm = heappop(heap)
        while arr[sm % n] != sm:
            sm = heappop(heap)
        op.append(sm)
        heappush(heap, sm)
    print("\n".join([str(x) for x in op]))
