from sys import stdin
from collections import defaultdict
import heapq


t, x = map(int, stdin.buffer.readline().split())

d = defaultdict(int)
h = []

for i in range(x):
  heapq.heappush(h, (0, i))


for _ in range(t):
  raw_num = int(stdin.buffer.readline())
  num = raw_num % x
  cur_count = d[num]
 
  d[num] += 1
  heapq.heappush(h, (cur_count + 1, num))
  
  while d[h[0][1]] != h[0][0]:
    heapq.heappop(h)


  print (h[0][0] * x + h[0][1]) 