from collections import defaultdict


def solution(ddict, base, st_pos):
    st_round = st_pos // base

    while True:
        for x in range(st_pos, base):
            if ddict[x] < st_round + 1:
                return st_round * base + x
        st_round += 1
        st_pos = 0
    return st_round * base



def read():
    r, base = tuple(map(int, input().split()))
    ddict = defaultdict(int)
    st_pos = 0
    for _ in range(r):
        value = int(input())
        ddict[value % base] += 1      
        result = solution(ddict, base, st_pos)
        print(result)
        st_pos = result

read()