from collections import defaultdict
import sys
def kek():
    q, x = map(int, input().split())
    arrAsk = []
    arrOst = [0] * x
    for _ in range(q):
        num = int(sys.stdin.readline())
        arrOst[num % x] += 1
        arrAsk.append(num)
    dic = defaultdict(set)

    arrAsk = list(reversed(arrAsk))
    for i in range(len((arrOst))):
        dic[arrOst[i]].add(i)

    minn = min(arrOst)
    out = []
    for i in range(len(arrAsk)):
        out.append(str(minn * x + min(dic[minn])))
        ind = arrAsk[i] % x
        dic[arrOst[ind]].remove(ind)
        arrOst[ind] -= 1
        dic[arrOst[ind]].add(ind)
        minn = min(arrOst[ind], minn)
    out = '\n'.join(out)
    sys.stdout.write(out[::-1])
kek()