from collections import defaultdict
def find_0(start, d, x):
    while True:
        if d[start % x] == 0:
            return start
        d[start % x] -= 1
        start += 1

def solve():
    q, x = map(int, input().split())
    nums = defaultdict(int)
    curr = 0
    for i in range(q):
        y = int(input())
        nums[y] += 1
        curr = find_0(curr, nums, x)
        print(curr)

solve()