from sys import stdin
from _collections import deque
mod = 10**9 + 7
import sys
sys.setrecursionlimit(10**5)
from queue import PriorityQueue
from bisect import bisect_right
from bisect import bisect_left
from _collections import defaultdict
from math import sqrt,factorial,gcd,log2,inf,ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify,heappush,heappop

# min = 0
# n,m = map(int,input().split())
# maxi = n
# z = m
# while z>0:
#
#     yo = (1+sqrt(1+8*z))//2
#     maxi-=yo
#     print(yo)
#     z-=((yo)*(yo+1))//2
#
#
# maxi = max(int(maxi),0)
#
#
#
# if m>=n-1:
#     min = 0
# else:
#     min = (n)-2*(m)
# #
# if m == 0:
#     print(n,n)
#     exit()
# if n == 1 and m == 1:
#     min = 1
# print(min,maxi)

q,x = map(int,input().split())
l = []
cur_ans = 0
seti = set()
for _ in range(q):

    z = int(input())
    if z == cur_ans:


        cur_ans+=1

        print(cur_ans)
        continue

    elif z-cur_ans == 1:
        pass
    elif z>cur_ans:
        z = z-(x*((z-cur_ans)//x))

    elif z<cur_ans:

        z = z+(x*ceil((cur_ans-z)/x))



    heapq.heappush(l,z)
    # print(z,l)

    while l:
        z = heapq.heappop(l)

        if z-cur_ans == 0:

            cur_ans+=1

        else:
            heapq.heappush(l,z)
            break

    print(cur_ans)
