Recall that MEX of an array is a minimum non-negative integer that does not belong to the array. Examples:  for the array $[0, 0, 1, 0, 2]$ MEX equals to $3$ because numbers $0, 1$ and $2$ are presented in the array and $3$ is the minimum non-negative integer not presented in the array;  for the array $[1, 2, 3, 4]$ MEX equals to $0$ because $0$ is the minimum non-negative integer not presented in the array;  for the array $[0, 1, 4, 3]$ MEX equals to $2$ because $2$ is the minimum non-negative integer not presented in the array. 

You are given an empty array $a=[]$ (in other words, a zero-length array). You are also given a positive integer $x$.

You are also given $q$ queries. The $j$-th query consists of one integer $y_j$ and means that you have to append one element $y_j$ to the array. The array length increases by $1$ after a query.

In one move, you can choose any index $i$ and set $a_i := a_i + x$ or $a_i := a_i - x$ (i.e. increase or decrease any element of the array by $x$). The only restriction is that $a_i$ cannot become negative. Since initially the array is empty, you can perform moves only after the first query.

You have to maximize the MEX (minimum excluded) of the array if you can perform any number of such operations (you can even perform the operation multiple times with one element).

You have to find the answer after each of $q$ queries (i.e. the $j$-th answer corresponds to the array of length $j$).

Operations are discarded before each query. I.e. the array $a$ after the $j$-th query equals to $[y_1, y_2, \dots, y_j]$.


-----Input-----

The first line of the input contains two integers $q, x$ ($1 \le q, x \le 4 \cdot 10^5$) — the number of queries and the value of $x$.

The next $q$ lines describe queries. The $j$-th query consists of one integer $y_j$ ($0 \le y_j \le 10^9$) and means that you have to append one element $y_j$ to the array.


-----Output-----

Print the answer to the initial problem after each query — for the query $j$ print the maximum value of MEX after first $j$ queries. Note that queries are dependent (the array changes after each query) but operations are independent between queries.


-----Examples-----
Input
7 3
0
1
2
2
0
0
10

Output
1
2
3
3
4
4
7

Input
4 3
1
2
1
2

Output
0
0
0
0



-----Note-----

In the first example:  After the first query, the array is $a=[0]$: you don't need to perform any operations, maximum possible MEX is $1$.  After the second query, the array is $a=[0, 1]$: you don't need to perform any operations, maximum possible MEX is $2$.  After the third query, the array is $a=[0, 1, 2]$: you don't need to perform any operations, maximum possible MEX is $3$.  After the fourth query, the array is $a=[0, 1, 2, 2]$: you don't need to perform any operations, maximum possible MEX is $3$ (you can't make it greater with operations).  After the fifth query, the array is $a=[0, 1, 2, 2, 0]$: you can perform $a[4] := a[4] + 3 = 3$. The array changes to be $a=[0, 1, 2, 2, 3]$. Now MEX is maximum possible and equals to $4$.  After the sixth query, the array is $a=[0, 1, 2, 2, 0, 0]$: you can perform $a[4] := a[4] + 3 = 0 + 3 = 3$. The array changes to be $a=[0, 1, 2, 2, 3, 0]$. Now MEX is maximum possible and equals to $4$.  After the seventh query, the array is $a=[0, 1, 2, 2, 0, 0, 10]$. You can perform the following operations:   $a[3] := a[3] + 3 = 2 + 3 = 5$,  $a[4] := a[4] + 3 = 0 + 3 = 3$,  $a[5] := a[5] + 3 = 0 + 3 = 3$,  $a[5] := a[5] + 3 = 3 + 3 = 6$,  $a[6] := a[6] - 3 = 10 - 3 = 7$,  $a[6] := a[6] - 3 = 7 - 3 = 4$.  The resulting array will be $a=[0, 1, 2, 5, 3, 6, 4]$. Now MEX is maximum possible and equals to $7$.

Difficulty: MEDIUM_HARD

Solutions:
import sys
from sys import stdin, stdout
import bisect
import math
import heapq

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
import math

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def main():
	(n, k) = cin()
	y = [-1] * k
	x = [0] * (n + 2)
	j = 0
	for i in range(n):
		p = inin()
		p = p % k
		y[p] += 1
		if y[p] * k + p <= n:
			x[y[p] * k + p] = 1
		while x[j] != 0:
			j += 1
		print(j)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


(q, x) = map(int, input().split())
l = [0] * x
n = 0
a = []
for i in range(q):
	l[int(input()) % x] += 1
	while l[n % x]:
		l[n % x] -= 1
		n += 1
	a.append(n)
print('\n'.join(map(str, a)))


from sys import stdin
(q, x) = map(int, stdin.readline().split())
(lst, result) = ([0] * x, 0)
for _ in range(q):
	query = int(stdin.readline())
	lst[query % x] += 1
	while lst[result % x] != 0:
		lst[result % x] -= 1
		result += 1
	print(result)


from sys import stdin
(query, x) = map(int, stdin.readline().split())
l = [0] * x
ans = 0
for _ in range(query):
	a = int(stdin.readline())
	l[a % x] += 1
	while l[ans % x] != 0:
		l[ans % x] -= 1
		ans += 1
	print(ans)


import sys, math, itertools
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush, heapify, nlargest
from copy import deepcopy
mod = 10 ** 9 + 7
INF = float('inf')

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))

def inpl_1():
	return list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))

def inps():
	return sys.stdin.readline()

def inpsl(x):
	tmp = sys.stdin.readline()
	return list(tmp[:x])

def err(x):
	print(x)
	exit()
(Q, X) = inpl()
mex = 0
sto = [0] * X
for i in range(Q):
	now = inp()
	sto[now % X] += 1
	while sto[mex % X] > 0:
		sto[mex % X] -= 1
		mex += 1
	print(mex)


import heapq
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(q, x) = list(map(int, input().split()))
lis = [0] * x
p = 0
for j in range(q):
	n = int(input())
	r = n % x
	lis[r] += 1
	while lis[p % x] > 0:
		lis[p % x] -= 1
		p += 1
	print(p)


def main():
	import sys
	(q, x) = map(int, input().split())
	s = [0] * x
	m = 0
	for i in range(q):
		if x == 1:
			print(i + 1)
		else:
			c = int(sys.stdin.readline())
			s[c % x] += 1
			while s[m % x] > 0:
				s[m % x] -= 1
				m = m + 1
			sys.stdout.write('\n' + str(m))
main()


import sys
input = sys.stdin.readline
(q, x) = [int(a) for a in input().split()]
arr = [0] * x
MEX = 0
for _ in range(q):
	y = int(input())
	arr[y % x] += 1
	while arr[MEX % x]:
		arr[MEX % x] -= 1
		MEX += 1
	print(MEX)


(q, x) = (int(i) for i in input().split())
C = [0] * x
a = []
ans = 0
for _ in range(q):
	C[int(input()) % x] += 1
	while C[ans % x] != 0:
		C[ans % x] -= 1
		ans += 1
	a.append(ans)
print('\n'.join(map(str, a)))


import sys
sys.setrecursionlimit(10 ** 7)
fin = lambda : sys.stdin.readline()
fout = lambda args: sys.stdout.write(' '.join((str(i) for i in args)) + '\n')
(q, x) = map(int, fin().split())
cnt = [0] * x
mex = 0
for _ in range(q):
	a = int(fin())
	cnt[a % x] += 1
	while cnt[mex % x]:
		cnt[mex % x] -= 1
		mex += 1
	fout([mex])


from collections import defaultdict
from sys import stdin
inp = stdin.readline
(q, x) = map(int, inp().split())
freq = defaultdict(int)
ans = 0
while q:
	q -= 1
	a = int(inp())
	freq[a % x] += 1
	while freq[ans % x] > 0:
		freq[ans % x] -= 1
		ans += 1
	print(ans)


import io, os
from sys import stdin
(q, x) = map(int, stdin.readline().split())
arr = [0] * x
array = []
for _ in range(q):
	(n,) = map(int, stdin.readline().split())
	array.append(n)
	arr[n % x] += 1
out = []
minn = arr[0]
ind = 0
for i in range(x):
	if arr[i] < minn:
		(minn, ind) = (arr[i], i)
for i in range(q):
	n = array.pop()
	out.append(minn * x + ind)
	arr[n % x] -= 1
	if arr[n % x] <= minn:
		if arr[n % x] == minn:
			if n % x < ind:
				ind = n % x
		else:
			ind = n % x
			minn = arr[n % x]
for i in out[::-1]:
	print(i)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve(case):
	(q, x) = sep()
	cnt = [0] * x
	have = {}
	ans = 0
	for i in range(q):
		curr = int(inp())
		have[cnt[curr % x] * x + curr % x] = 1
		cnt[curr % x] += 1
		while ans in have:
			ans += 1
		print(ans)
testcase(1)


from math import floor
from math import sqrt
from math import ceil
from itertools import combinations, accumulate, groupby, count
from sys import stdout, stdin, setrecursionlimit
from io import BytesIO, IOBase
from collections import *
from random import *
from bisect import *
from string import *
from queue import *
from heapq import *
from math import *
from os import *
from re import *

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = read(self._fd, max(fstat(self._fd).st_size, 8192))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = read(self._fd, max(fstat(self._fd).st_size, 8192))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(stdin, stdout) = (IOWrapper(stdin), IOWrapper(stdout))

def fast():
	return stdin.readline().strip()

def zzz():
	return [int(i) for i in fast().split()]
(z, zz) = (fast, lambda : list(map(int, z().split())))
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def output(answer, end='\n'):
	stdout.write(str(answer) + end)
dx = [-1, 1, 0, 0, 1, -1, 1, -1]
dy = [0, 0, 1, -1, 1, -1, -1, 1]
(q, x) = zzz()
d = {}
for i in range(x):
	d[i] = 0
mx = 0
done = {}
for i in range(q):
	n = int(z())
	n %= x
	d[n] += 1
	n += (d[n] - 1) * x
	done[n] = 1
	while mx in done:
		mx += 1
	output(mx)


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
(q, x) = map(int, input().split())
a = [0] * x
maxx = 0
for _ in range(q):
	n = int(input())
	a[n % x] += 1
	while a[maxx % x] != 0:
		a[maxx % x] -= 1
		maxx += 1
	print(maxx)


from collections import *
(q, x) = map(int, input().split())
(dis, mem, ans, mi) = ({(0, i) for i in range(x)}, [0] * x, [], 0)
for i in range(q):
	n = int(input())
	mem[n % x] += 1
	while mem[mi % x]:
		mem[mi % x] -= 1
		mi += 1
	ans.append(str(mi))
print('\n'.join(ans))


ls = list(map(int, input().split()))
arri = []
x = ls[1]
nls = [0] * x
mexi = 0
for i in range(ls[0]):
	nls[int(input()) % x] += 1
	if x == 1:
		mexi = i + 1
	else:
		while nls[mexi % x]:
			nls[mexi % x] -= 1
			mexi += 1
	arri.append(mexi)
print('\n'.join(map(str, arri)))


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max, nsmallest, nlargest

def main():
	mod = 1000000007
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	tc = 1
	for _ in range(tc):
		(q, x) = ria()
		a = []
		c = 0
		ans = [0] * q
		prev = 0
		d = {}
		for i in range(q):
			y = ri()
			a.append(y)
			z = y - y // x * x
			k = z
			if k in d:
				z = d[k] + x
			while z < q:
				if ans[z] == 0:
					ans[z] = 1
					d[k] = z
					break
				z += x
			k = 0
			for j in range(prev, q):
				if ans[j] == 0:
					k = 1
					prev = j
					wi(j)
					break
			if k == 0:
				wi(q)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


import math
for contorr in range(1):
	(q, x) = list(map(int, input().split()))
	limita = 400001
	vector = [-1] * x
	answ = [0] * limita
	total = []
	mex = 0
	for jj in range(q):
		j = int(input())
		part = j % x
		vector[part] += 1
		if part + x * vector[part] < limita:
			answ[part + x * vector[part]] = 1
		posibil = 1
		while posibil == 1:
			posibil = 0
			if mex < limita:
				if answ[mex] != 0:
					mex += 1
					posibil = 1
		total.append(mex)
for z in total:
	print(z)


(q, x) = map(int, input().split())
mx = 4 * 10 ** 5 + 1
t_reszt = [0] * mx
t_wyn = [0] * mx
t_out = []
curr_ind = 0
out_curr_ind = 0
for y in range(q):
	curr_val = int(input())
	m = curr_val % x
	ii = t_reszt[m] * x + m
	if ii < mx - 1:
		t_wyn[ii] = 1
	t_reszt[m] += 1
	curr_ind = out_curr_ind
	for z in range(curr_ind, len(t_wyn), +1):
		if t_wyn[z] == 0:
			t_out.append(z)
			out_curr_ind = z
			break
print('\n'.join(map(str, t_out)))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import defaultdict
(q, x) = map(int, input().split())
mex = 0
pending = defaultdict(int)
for _ in range(q):
	y = int(input())
	pending[y % x] += 1
	while pending[mex % x] > 0:
		pending[mex % x] -= 1
		mex += 1
	print(mex)


import sys
input = sys.stdin.readline
(q, x) = map(int, input().split())
d = {}
for i in range(x):
	d[i] = 0
mex = 0
done = {}
for i in range(q):
	n = int(input())
	n = n % x
	d[n] += 1
	n = n + (d[n] - 1) * x
	done[n] = 1
	while mex in done:
		mex += 1
	print(mex)


import sys
input = sys.stdin.buffer.readline

def main():
	(Q, X) = map(int, input().split())
	A = [0] * X

	def segfunc(x, y):
		if x[0] < y[0]:
			return x
		elif x[0] == y[0]:
			if x[1] <= y[1]:
				return x
			else:
				return y
		else:
			return y

	def init(init_val):
		for i in range(X):
			seg[i + num - 1] = [init_val[i], i]
		for i in range(num - 2, -1, -1):
			seg[i] = segfunc(seg[2 * i + 1], seg[2 * i + 2])

	def update(k, x):
		k += num - 1
		seg[k][0] += x
		while k:
			k = (k - 1) // 2
			seg[k] = segfunc(seg[2 * k + 1], seg[2 * k + 2])

	def query(p, q):
		if q <= p:
			return ide_ele
		p += num - 1
		q += num - 2
		res = [ide_ele, X]
		while q - p > 1:
			if p & 1 == 0:
				res = segfunc(res, seg[p])
			if q & 1 == 1:
				res = segfunc(res, seg[q])
				q -= 1
			p = p // 2
			q = (q - 1) // 2
		if p == q:
			res = segfunc(res, seg[p])
		else:
			res = segfunc(segfunc(res, seg[p]), seg[q])
		return res
	ide_ele = 10 ** 18
	num = 2 ** (X - 1).bit_length()
	seg = [[ide_ele, X] for _ in range(2 * num)]
	init(A)
	for i in range(Q):
		y = int(input())
		y %= X
		update(y, 1)
		(c, idx) = query(0, X)
		print(c * X + idx)
main()


import sys
(q, x) = [int(i) for i in input().split()]
d = [0] * x
mx = -1
for i in range(q):
	qqq = int(sys.stdin.readline())
	d[qqq % x] += 1
	while True:
		mm = (mx + 1) % x
		if d[mm] >= (mx + 1) // x + 1:
			mx += 1
		else:
			break
	print(mx + 1)


import sys

def getN():
	return int(input())

def getNM():
	return map(int, input().split())

def getList():
	return list(map(int, input().split()))

def input():
	return sys.stdin.readline().rstrip()
(q, x) = getNM()
arr = [0] * x
n = 0
for _ in range(q):
	num = getN()
	arr[num % x] += 1
	while arr[n % x]:
		arr[n % x] -= 1
		n += 1
	print(n)


import sys
input = sys.stdin.readline

def segtree(i, l, r, arr):
	if l == r:
		tree[i] = arr[l]
		return tree[i]
	m = (l + r) // 2
	tree[i] = min(segtree(2 * i + 1, l, m, arr), segtree(2 * i + 2, m + 1, r, arr))
	return tree[i]

def update(i, l, r, num, ind):
	if ind < l or ind > r:
		return
	elif l == r:
		tree[i] = num
		return
	m = (l + r) // 2
	update(2 * i + 1, l, m, num, ind)
	update(2 * i + 2, m + 1, r, num, ind)
	tree[i] = min(tree[2 * i + 1], tree[2 * i + 2])
	return

def search(i, l, r, num):
	if l == r:
		return l
	m = (l + r) // 2
	if tree[2 * i + 1] == num:
		return search(2 * i + 1, l, m, num)
	else:
		return search(2 * i + 2, m + 1, r, num)
(q, x) = map(int, input().split())
arr = [0] * x
i = 0
while 2 ** i < x:
	i = i + 1
tree = [0] * (2 ** (i + 1) - 1)
segtree(0, 0, x - 1, arr)
for _ in range(q):
	y = int(input())
	arr[y % x] += 1
	update(0, 0, x - 1, arr[y % x], y % x)
	i = search(0, 0, x - 1, tree[0])
	if tree[0] == 0:
		print(i)
	elif i == 0:
		sys.stdout.write(str(x * tree[0]) + '\n')
	else:
		sys.stdout.write(str(x * tree[0] + i) + '\n')


from sys import stdin, stdout
t = 1
for i in range(t):
	(q, x) = map(int, stdin.readline().split())
	mul = [0] * x
	ANS = 0
	ans = [False] * 500000
	for i in range(q):
		y = int(stdin.readline())
		m = y % x
		if mul[m] * x + m < 500000:
			ans[mul[m] * x + m] = True
			mul[m] += 1
		while ans[ANS]:
			ANS += 1
		stdout.write(str(ANS) + '\n')


from heapq import *
import sys
(q, n) = [int(__) for __ in input().strip().split()]
input = sys.stdin.readline
arr = list(range(n))
heap = []
op = []
for x in arr:
	heappush(heap, x)
for _ in range(q):
	inp = int(input()) % n
	arr[inp] += n
	heappush(heap, arr[inp])
	sm = heappop(heap)
	while arr[sm % n] != sm:
		sm = heappop(heap)
	op.append(sm)
	heappush(heap, sm)
print('\n'.join(map(str, op)))


import os, sys, atexit
from io import BytesIO, StringIO
input = BytesIO(os.read(0, os.fstat(0).st_size)).readline
_OUTPUT_BUFFER = StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
(q, x) = map(int, input().split())
arr = [0] * (4 * 100005)
m = 0
while q:
	q += -1
	y = int(input())
	arr[y % x] -= -1
	while arr[m % x]:
		arr[m % x] += -1
		m -= -1
	print(m)


(n, x) = map(int, input().split(' '))
ans = []
now = [0] * x
count = 0
for _ in range(n):
	y = int(input())
	now[y % x] += 1
	while now[count % x] != 0:
		now[count % x] -= 1
		count += 1
	ans.append(count)
print(*ans, sep=' ', end='\n')


import sys, time
input = sys.stdin.readline
start_time = time.time()
MAX_N = int(400000.0 + 50)
(q, x) = map(int, input().split())
ans = 0
visited = [0 for _ in range(x)]
for _ in range(q):
	y = int(input())
	visited[y % x] += 1
	while visited[ans % x] != 0:
		visited[ans % x] -= 1
		ans += 1
	print(ans)


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
input = sys.stdin.readline
(q, x) = mi()
d = [i % x - x for i in range(x)]
s = [0] * (q + 2)
i = 0
res = []
for _ in range(q):
	n = ii()
	d[n % x] += x
	if d[n % x] <= q + 1:
		s[d[n % x]] = 1
	while s[i]:
		i += 1
	res.append(i)
prr(res, '\n')


import sys
import heapq
(q, x) = map(int, sys.stdin.readline().rstrip().split())
target = 0
h = dict()
for _ in range(q):
	n = int(sys.stdin.readline().rstrip())
	if target % x == n % x:
		target += 1
		while True:
			if len(h) == 0:
				break
			try:
				if h[target % x] >= 1:
					h[target % x] -= 1
					target += 1
				else:
					break
			except:
				break
		print(target)
	else:
		try:
			h[n % x] += 1
		except:
			h[n % x] = 1
		while True:
			if len(h) == 0:
				break
			try:
				if h[target % x] >= 1:
					target += 1
					h[target % x] -= 1
				else:
					break
			except:
				break
		print(target)


import sys
input = sys.stdin.buffer.readline

def solution():
	cnt = [0] * (4 * 10 ** 5 + 2)
	(q, x) = map(int, input().split())
	i = 0
	s = set()
	for _ in range(q):
		n = int(input())
		z = n % x
		cnt[z] += 1
		while cnt[i % x]:
			cnt[i % x] -= 1
			i += 1
		print(i)
solution()


import sys
(q, x) = map(int, sys.stdin.readline().split())
cnt = [0] * x
cur = 0
for _ in range(q):
	y = int(sys.stdin.readline())
	cnt[y % x] += 1
	while cnt[cur % x] > 0:
		cnt[cur % x] -= 1
		cur += 1
	print(cur)


import sys
from heapq import *
input = sys.stdin.readline
(quer, m) = list(map(int, input().split()))
vals = list(range(m))
q = []
for v in vals:
	heappush(q, v)
out = []
for _ in range(quer):
	nex = int(input()) % m
	vals[nex] += m
	heappush(q, vals[nex])
	new = heappop(q)
	while vals[new % m] != new:
		new = heappop(q)
	out.append(new)
	heappush(q, new)
print('\n'.join(map(str, out)))


import atexit
import io
import sys
input = sys.stdin.readline
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
(q, x) = map(int, input().split())
a = [0] * x
mex = 0
out = []
for i in range(q):
	a[int(input()) % x] += 1
	while a[mex % x] > 0:
		a[mex % x] -= 1
		mex += 1
	out.append(mex)
print(*out)


from __future__ import division, print_function
import os
import sys, math
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def main():
	(q, x) = map(int, input().split())
	ma = dict()
	se = set()
	ans = 0
	while q:
		q -= 1
		n = int(input())
		val = n % x
		if ma.get(val) is None:
			ma[val] = val
		else:
			ma[val] += x
		se.add(ma[val])
		while ans in se:
			ans += 1
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


(t, k) = map(int, input().split())
num = [0] * k
mex = 0
anse = []
for i in range(t):
	num[int(input()) % k] += 1
	while num[mex % k] > 0:
		num[mex % k] -= 1
		mex += 1
	anse.append(mex)
print(*anse)


import sys
input = sys.stdin.readline
(q, x) = map(int, input().split())
k = [0 for _ in range(x)]
m = 0
for i in range(q):
	g = int(input())
	k[g % x] += 1
	while k[m % x] > 0:
		k[m % x] -= 1
		m += 1
	print(m)


class MinHeap:

	class Node:

		def __init__(self, i, key, priority):
			self.i = i
			self.key = key
			self.priority = priority

		def __repr__(self):
			return 'Node[i:{} k:{} p:{}]'.format(self.i, self.key, self.priority)

	def sift_up(self, i):
		while i > 0:
			p = (i - 1) // 2
			if self.heap[i].priority < self.heap[p].priority:
				(self.heap[i].i, self.heap[p].i) = (p, i)
				(self.heap[i], self.heap[p]) = (self.heap[p], self.heap[i])
				i = p
			else:
				break

	def sift_down(self, i):
		while 2 * i + 1 < len(self.heap):
			m = i
			l = 2 * i + 1
			if self.heap[l].priority < self.heap[m].priority:
				m = l
			r = l + 1
			if r < len(self.heap) and self.heap[r].priority < self.heap[m].priority:
				m = r
			if m != i:
				(self.heap[i].i, self.heap[m].i) = (m, i)
				(self.heap[i], self.heap[m]) = (self.heap[m], self.heap[i])
				i = m
			else:
				break

	def lowest_priority(self):
		return self.heap[0].priority

	def lowest_priority_key(self):
		return self.heap[0].key

	def get_priority(self, key):
		return self.mapping[key].priority

	def set_priority(self, key, new_priority):
		node = self.mapping[key]
		if new_priority < node.priority:
			node.priority = new_priority
			self.sift_up(node.i)
		elif new_priority > node.priority:
			node.priority = new_priority
			self.sift_down(node.i)

	def add_priority(self, key, priority):
		node = self.Node(len(self.heap), key, priority)
		self.mapping[key] = node
		self.heap.append(node)
		self.sift_up(len(self.heap) - 1)

	def remove_priority(self, key):
		node = self.mapping[key]
		if node.i < len(self.heap) - 1:
			replacement_node = self.heap.pop()
			self.heap[node.i] = replacement_node
			replacement_node.i = node.i
			if replacement_node.priority < node.priority:
				self.sift_up(node.i)
			elif replacement_node.priority > node.priority:
				self.sift_down(node.i)
		else:
			self.heap.pop()
		del self.mapping[key]

	def __init__(self, priorities={}):
		if priorities is not None:
			self.mapping = {}
			self.heap = []
			for (key, priority) in priorities.items():
				node = self.Node(len(self.heap), key, priority)
				self.mapping[key] = node
				self.heap.append(node)
		for i in range(len(self.heap) - 1, -1, -1):
			self.sift_up(i)

	def __len__(self):
		return len(self.heap)

	def __repr__(self):
		return repr(self.heap)
import sys
(q, x) = (int(v) for v in sys.stdin.readline().split())
H = MinHeap({m: (0, m) for m in range(x)})
for i in range(q):
	n = int(sys.stdin.readline())
	m = n % x
	(mis_n, mis_m) = H.get_priority(m)
	H.set_priority(m, (mis_n + 1, mis_m))
	(mis_n, mis_m) = H.lowest_priority()
	print(mis_n * x + mis_m)


(T, X) = map(int, input().split())
A = []
C = [0] * X
N = 0
for _ in range(T):
	C[int(input()) % X] += 1
	while C[N % X]:
		C[N % X] -= 1
		N += 1
	A.append(N)
print('\n'.join(map(str, A)))


from collections import Counter
from sys import stdin

def input():
	return next(stdin)

def main():
	(q, x) = map(int, input().split())
	aa = []
	counts = Counter()
	mex = 0
	for _ in range(q):
		a = int(input()) % x
		counts[a] += 1
		while counts[mex % x] > 0:
			counts[mex % x] -= 1
			mex += 1
		print(mex)
main()


(q, x) = map(int, input().split())
mod = [0] * x
ans = 0
ans_array = []
for i in range(q):
	mod[int(input()) % x] += 1
	while mod[ans % x]:
		mod[ans % x] -= 1
		ans += 1
	ans_array.append(ans)
print('\n'.join(map(str, ans_array)))


from sys import stdin, stdout
(q, x) = map(int, stdin.readline().split())
d = {i: 0 for i in range(x)}
segs = {0: 0}
queries = []
for _ in range(q):
	i = int(stdin.readline().strip()) % x
	queries.append(i)
	d[i] += 1
m = min(d.values())
cur = next(filter(lambda x: x[1] == m, d.items()))[0] + m * x
lines = []
for i in reversed(queries):
	lines.append('{}\n'.format(cur))
	d[i] -= 1
	cur = min(d[i] * x + i, cur)
stdout.writelines(reversed(lines))


(q, x) = map(int, input().split())
a = [0] * x
mex = 0
out = []
for i in range(q):
	a[int(input()) % x] += 1
	while a[mex % x] > 0:
		a[mex % x] -= 1
		mex += 1
	out.append(mex)
print(*out)


import sys
(q, x) = map(int, input().split())
cnt = [0] * x
e = 0
for i in range(q):
	if x == 1:
		print(i + 1)
	else:
		a = int(sys.stdin.readline())
		cnt[a % x] += 1
		while cnt[e % x]:
			cnt[e % x] -= 1
			e += 1
		sys.stdout.write(str(e) + '\n')


(q, x) = map(int, input().split())
a = [0] * (x + 1)
(mex, ans) = (0, '')
while q > 0:
	q -= 1
	val = int(input())
	a[val % x] += 1
	while a[mex % x] > 0:
		a[mex % x] -= 1
		mex += 1
	ans += str(mex) + '\n'
print(ans)


(n, x) = map(int, input().split())
mlook = 0
available = [0] * x
mex = -1
ans = [0] * n
for _ in range(n):
	num = int(input())
	if num == mex + 1 or mlook == num % x:
		mex += 1
		mlook = (mlook + 1) % x
		while available[mlook] > 0:
			available[mlook] -= 1
			mex += 1
			mlook = (mlook + 1) % x
	else:
		available[num % x] += 1
	ans[_] = mex + 1
print('\n'.join((str(ans[k]) for k in range(n))))


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
(q, x) = map(int, input().split())
l = [0] * x
ans = 0
yo = []
for _ in range(q):
	z = int(input())
	l[z % x] += 1
	while l[ans % x]:
		l[ans % x] -= 1
		ans += 1
	yo.append(ans)
print('\n'.join(map(str, yo)))


import sys
input = sys.stdin.readline
(q, x) = map(int, input().split())
a = [0] * x
ans = 0
for i in range(q):
	n = int(input())
	a[n % x] += 1
	while a[ans % x]:
		a[ans % x] -= 1
		ans += 1
	print(ans)


import sys
input = sys.stdin.readline
(q, x) = map(int, input().split())
nfr = [0 for i in range(x)]
ans = 0
for i in range(q):
	now = int(input())
	nfr[now % x] += 1
	while nfr[ans % x]:
		nfr[ans % x] -= 1
		ans += 1
	print(ans)


from sys import stdin, stdout
import collections
import heapq
import itertools
import functools

def read_line():
	return stdin.readline().strip()

def read_int():
	return int(read_line())

def read_arr():
	return read_line().split(' ')

def read_int_arr():
	return [int(x) for x in read_arr()]

def query_interactive(s):
	print(s)
	stdout.flush()

def main():
	(q, x) = read_int_arr()
	mods = collections.defaultdict(int)
	cur = 0
	for i in range(0, x):
		mods[i] = 0
	for _ in range(q):
		qu = read_int()
		mod = qu % x
		mods[mod] += 1
		while mods[cur % x] > 0:
			mods[cur % x] -= 1
			cur += 1
		print(cur)
main()


(q, x) = [int(i) for i in input().split(' ')]
cc = [0] * x
mex = 0
res = []
for _ in range(q):
	y = int(input())
	y = y % x
	cc[y] += 1
	while cc[mex % x] > 0:
		cc[mex % x] -= 1
		mex += 1
	res.append(mex)
print('\n'.join(map(str, res)))


from sys import stdin, stdout
(q, x) = map(int, stdin.readline().split())
modx = [0] * x
ans = 0
for i in range(q):
	item = int(stdin.readline())
	modx[item % x] += 1
	while modx[ans % x] > 0:
		modx[ans % x] -= 1
		ans += 1
	stdout.write('{}\n'.format(ans))


(q, n) = map(int, input().split())
levelCount = [0] * n
a = []
x = 0
for _ in range(q):
	levelCount[int(input()) % n] += 1
	while levelCount[x % n]:
		levelCount[x % n] -= 1
		x += 1
	a.append(x)
print('\n'.join(map(str, a)))


from sys import stdin, stdout
import os.path
if os.path.isfile('inp.txt'):
	stdin = open('inp.txt', 'r')
res = 0
d = [0 for i in range(400005)]
(q, x) = map(int, stdin.readline().split())
for _ in range(q):
	n = int(stdin.readline())
	d[n % x] += 1
	while d[res % x] > res / x:
		res += 1
	print(res)


MAX_N = 400005
(query, x) = map(int, input().strip().split())
count = [0 for _ in range(MAX_N)]
mex = 0
ans = ''
for i in range(query):
	y = int(input().strip())
	count[y % x] += 1
	while True:
		if count[mex % x] > 0:
			count[mex % x] -= 1
			mex += 1
		else:
			break
	ans += str(mex) + '\n'
print(ans)


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return list(map(int, minp().split()))

def solve():
	(n, x) = mints()
	c = [0] * x
	ans = 0
	for i in range(n):
		y = mint()
		c[y % x] += 1
		while c[ans % x] > 0:
			c[ans % x] -= 1
			ans += 1
		print(ans)
solve()


import sys
(n, k) = map(int, input().split())
a = [0] * k
c = 0
s = []
for j in range(n):
	a[int(sys.stdin.readline()) % k] += 1
	while a[c % k] > 0:
		a[c % k] -= 1
		c += 1
	s.append(c)
print('\n'.join(map(str, s)))


import sys
input = sys.stdin.readline
(q, x) = map(int, input().split())
seg_el = 1 << (x + 1).bit_length()
SEG = [0] * (2 * seg_el)

def add1(n, seg_el):
	i = n + seg_el
	SEG[i] += 1
	i >>= 1
	while i != 0:
		SEG[i] = min(SEG[i * 2], SEG[i * 2 + 1])
		i >>= 1

def getvalues(l, r):
	L = l + seg_el
	R = r + seg_el
	ANS = 1 << 30
	while L < R:
		if L & 1:
			ANS = min(ANS, SEG[L])
			L += 1
		if R & 1:
			R -= 1
			ANS = min(ANS, SEG[R])
		L >>= 1
		R >>= 1
	return ANS
for qu in range(q):
	t = int(input())
	add1(t % x, seg_el)
	MIN = getvalues(0, x)
	OK = 0
	NG = x
	while NG - OK > 1:
		mid = (OK + NG) // 2
		if getvalues(0, mid) > MIN:
			OK = mid
		else:
			NG = mid
	print(MIN * x + OK)


import sys
input = sys.stdin.readline
from collections import defaultdict
(q, x) = [int(i) for i in input().rstrip('\n').split()]
(d, lastmin) = [defaultdict(int)] * 2
currcount = 0
for i in range(q):
	ele = int(input())
	lastmin[ele % x] += 1
	d[x * (lastmin[ele % x] - 1) + ele % x] = 1
	while d[currcount]:
		currcount += 1
	print(currcount)


(n, x) = map(int, input().split())
output = []
c = [0] * x
m = 0
for _ in range(n):
	t = int(input())
	c[t % x] += 1
	while c[m % x] != 0:
		c[m % x] -= 1
		m += 1
	output.append(m)
print(*output, sep='\n')


(q, x) = map(int, input().split())
a = [0] * (x + 1)
for i in range(x):
	a[i] = 0
(mex, base) = (0, 0)
ans = ''
while q > 0:
	q -= 1
	val = int(input())
	a[val % x] += 1
	while a[mex] > 0:
		mex += 1
		if mex == x:
			base += 1
			mex = 0
			for i in range(x):
				a[i] -= 1
	ans += str(base * x + mex) + '\n'
print(ans)


import sys
from collections import defaultdict
(q, x) = map(int, sys.stdin.readline().split())
import heapq
viss = defaultdict(int)
arr = [[0, i] for i in range(x)]
heapq.heapify(arr)
for _ in range(q):
	y = int(sys.stdin.readline())
	c = y % x
	viss[c] += 1
	heapq.heappush(arr, [viss[c], c])
	while arr[0][0] != viss[arr[0][1]]:
		heapq.heappop(arr)
	(a, b) = arr[0]
	print(a * x + b)


import math as mt
import sys, string
input = sys.stdin.readline
from collections import defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
(q, x) = M()
l = []
for i in range(x):
	l.append(i)
d = defaultdict(int)
ind = 0
for i in range(q):
	w = I()
	w %= x
	d[l[w]] += 1
	l[w] += x
	while d[ind]:
		ind += 1
	print(ind)


(q, x) = map(int, input().split())
y = [0] * x
ans = list()
zero_ind = set()
zero = [1] * x
d = 1
for kek in range(q):
	a = int(input())
	a %= x
	y[a] += 1
	if len(zero) >= x - a:
		zero[x - a - 1] = 0
	while len(zero) > 0 and zero[-1] == 0:
		zero.pop()
	if len(zero) == 0:
		d += 1
		zero = [1] * x
		for i in range(x):
			y[i] -= 1
			if y[i] != 0:
				zero[x - i - 1] = 0
	while len(zero) > 0 and zero[-1] == 0:
		zero.pop()
	ans.append(d * x - len(zero))
print(*ans, sep='\n')


import sys
input = sys.stdin.readline
(q, x) = map(int, input().split())
d = {}
ans = 0
for _ in range(q):
	y = int(input())
	c = y % x
	if c in d:
		d[c] += 1
	else:
		d[c] = 1
	while True:
		v = ans % x
		if v in d:
			ans += 1
			d[v] -= 1
			if d[v] == 0:
				del d[v]
		else:
			break
	sys.stdout.write(str(ans) + '\n')


import math
from functools import reduce
(n, x) = map(int, input().split(' '))
ans = []
now = [0] * x
m = 0
for _ in range(n):
	y = int(input())
	now[y % x] += 1
	while now[m % x] != 0:
		now[m % x] -= 1
		m += 1
	ans.append(m)
print(*ans, sep=' ', end='\n')


import sys
input = sys.stdin.readline
from collections import defaultdict
(t, x) = map(int, input().split())
d = defaultdict(int)
w = defaultdict(int)
for i in range(x):
	w[i] = i
i = 0
for _ in range(t):
	y = int(input())
	y %= x
	d[w[y]] += 1
	w[y] += x
	while d[i]:
		i += 1
	print(i)


import sys
input = sys.stdin.readline
(q, x) = map(int, input().split())
dp = [0] * x
p = 0
m = 0
for _ in range(q):
	y = int(input())
	dp[y % x] += 1
	while dp[m % x] > 0:
		dp[m % x] -= 1
		m += 1
	print(m)


def solve(x, queries):
	surplus = [0] * x
	mex = 0
	for q in queries:
		surplus[q % x] += 1
		while surplus[mex % x] > 0:
			surplus[mex % x] -= 1
			mex += 1
		yield mex
(q, x) = map(int, input().split())
for result in solve(x, [int(input()) for i in range(q)]):
	print(result)


from sys import stdin

def solve():
	(q, x) = map(int, stdin.readline().split())
	d = {}
	(mx, mex) = (0, 0)
	for _ in range(q):
		mx += 1
		n = int(stdin.readline())
		d.setdefault(n % x, 0)
		d[n % x] += 1
		while mex < mx:
			if mex % x in d and d[mex % x] >= 1:
				d[mex % x] -= 1
				mex += 1
			else:
				break
		print(mex)
solve()


from sys import stdin
from collections import defaultdict
input = stdin.readline
(q, x) = map(int, input().split())
mex = 0
box = defaultdict(int)
for i in range(q):
	y = int(input())
	box[y % x] += 1
	while box[mex % x] > 0:
		box[mex % x] -= 1
		mex += 1
	print(mex)


import sys
input = sys.stdin.buffer.readline
import os
from math import *
(t, x) = map(int, input().split())
arr = [0] * x
i = 0
ans = 0
while t:
	t -= 1
	n = int(input())
	arr[n % x] += 1
	while arr[ans] > i:
		ans += 1
		if ans % x == 0:
			i += 1
			ans = 0
	print(i * x + ans)


import sys
input = sys.stdin.readline
from heapq import *
(q, x) = map(int, input().split())
a = list(range(0, x))
h = []
for i in a:
	heappush(h, i)
out = []
for _ in range(q):
	n = int(input())
	val = n % x
	a[val] += x
	heappush(h, a[val])
	z = heappop(h)
	while a[z % x] != z:
		z = heappop(h)
	out.append(z)
	heappush(h, z)
print('\n'.join(map(str, out)))


import sys
input = sys.stdin.readline
(q, x) = map(int, input().split())
s = [0] * x
m = 0
for i in range(q):
	c = int(input())
	s[c % x] += 1
	while s[m % x] > 0:
		s[m % x] -= 1
		m = m + 1
	print(m)


import sys
from collections import Counter

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
(Q, X) = MAP()
A = [a % X for a in LIST(Q)]
A = A[::-1]
C = Counter(A)
mn = min([C[a] for a in range(X)])
add = 0
for a in range(X):
	if C[a] == mn:
		add = a
		break
base = mn * X
ans = []
for a in A:
	ans.append(base + add)
	C[a] -= 1
	if C[a] == mn:
		add = min(add, a)
	elif C[a] < mn:
		mn -= 1
		base -= X
		add = a
[print(a) for a in ans[::-1]]


(a, b) = list(map(int, input().strip().split(' ')))
c = [0] * b
m = 0
ans = []
for i in range(a):
	y = int(input().strip())
	c[y % b] += 1
	while c[m % b] > m / b:
		m += 1
	ans.append(m)
print('\n'.join(map(str, ans)))


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())
(q, x) = map(int, input().split())
remain = [0] * x
mex = 0
for _ in range(q):
	y = mint()
	remain[y % x] += 1
	while remain[mex % x] > 0:
		remain[mex % x] -= 1
		mex += 1
	print(mex)


import sys
input = sys.stdin.readline
(q, x) = map(int, input().split())
a = [0] * x
maxx = 0
for _ in range(q):
	n = int(input())
	a[n % x] += 1
	while a[maxx % x] != 0:
		a[maxx % x] -= 1
		maxx += 1
	print(maxx)


[n, x] = list(map(int, input().split(' ')))
arr = [0 for i in range(x)]
index = 0
ans = []
if 0:
	none = 0
else:
	for i in range(n):
		k = int(input())
		arr[k % x] += 1
		while arr[index % x] != 0:
			arr[index % x] -= 1
			index += 1
		ans.append(index)
	for i in ans:
		print(i)


from collections import Counter
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

def solve(adj, colors, n):
	pass

def root(parent, a):
	while parent[a] != a:
		parent[a] = parent[parent[a]]
		a = parent[a]
	return a

def union(parent, size, a, b):
	(roota, rootb) = (root(parent, a), root(parent, b))
	if roota == rootb:
		return
	parent[rootb] = roota
	size[roota] += size[rootb]
	size[rootb] = 0

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
(n, x) = rinput()
d = [0] * x
mn = -1
ans = 0
for _ in range(n):
	q = iinput()
	d[q % x] += 1
	while d[ans % x] > 0:
		d[ans % x] -= 1
		ans += 1
	print(ans)


(l, k) = map(int, input().split())
lis = [0] * k
i = 0
A = []
for z in range(l):
	lis[int(input()) % k] += 1
	while lis[i % k]:
		lis[i % k] -= 1
		i = i + 1
	A.append(i)
print('\n'.join(map(str, A)))


import sys

def get():
	global x, now_min
	res = [0, 1000000000]
	token = 0
	for i in range(x):
		c = list_cycle[i]
		if c == now_min:
			res = [i, c]
			token = 1
			break
		if c < res[1]:
			res = [i, c]
	if not token:
		now_min += 1
	return res[1] * x + res[0]
(q, x) = map(int, sys.stdin.readline().split())
list_cycle = [0 for _ in range(x)]
(now_min, pointer) = (0, 0)
for i in range(q):
	now = int(sys.stdin.readline())
	list_cycle[now % x] += 1
	while list_cycle[pointer % x] > pointer // x:
		pointer += 1
	print(pointer)


import sys
input = sys.stdin.readline
(q, x) = map(int, input().split())
LIST = [0] * x
mex = 0
for qu in range(q):
	LIST[int(input()) % x] += 1
	while LIST[mex % x] > mex // x:
		mex += 1
	print(mex)


import sys

def main():
	input = sys.stdin.readline
	(q, x) = [int(i) for i in input().split()]
	A = [0 for i in range(x)]
	m = 0
	c = 0
	ans = []
	for a in range(q):
		n = int(input())
		A[n % x] += 1
		while A[c] >= m // x + 1:
			c = (c + 1) % x
			m += 1
		ans.append(str(m))
	print('\n'.join(ans))

def __starting_point():
	main()
__starting_point()


def f(x, mex, mod_count):
	while mod_count.get(mex % x, False):
		mod_count[mex % x] -= 1
		mex += 1
	return mex
(q, x) = list(map(int, input().split()))
mod_count = {}
mex = 0
result = ''
for _ in range(q):
	if x != 1:
		mod = int(input()) % x
		mod_count[mod] = mod_count.get(mod, 0) + 1
		mex = f(x, mex, mod_count)
	else:
		mex = _ + 1
	result += str(mex)
	result += '\n'
print(result)


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from bisect import *
from math import sqrt, pi, ceil, log, inf, gcd
from itertools import permutations
from copy import deepcopy
from heapq import *
from sys import setrecursionlimit

def main():
	(q, x) = map(int, input().split())
	j = 0
	b = []
	heapify(b)
	c = {}
	for i in range(q):
		y = int(input())
		t = abs(j - y)
		if t % x == 0:
			j += 1
			while len(b) != 0:
				z = heappop(b)
				if z != j:
					heappush(b, z)
					break
				j += 1
		else:
			z = y - t // x * x if y > j else y + (t // x + 1) * x
			if c.get(z) == None:
				c[z] = z + x
			else:
				a = []
				while c.get(z) != None:
					a.append(z)
					z = c[z]
				a.append(z)
				for i in a:
					c[i] = z + x
			heappush(b, z)
		print(j)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


(q, x) = map(int, input().split())
sachin = []
count1 = 0
count2 = 0
arr = []
out = []
for i in range(x):
	arr.append(0)
for i in range(q):
	val = int(input())
	arr[val % x] += 1
	while arr[count2 % x] > count1:
		count2 += 1
		if count2 % x == 0:
			count1 += 1
	out.append(count2)
print('\n'.join(map(str, out)))


import sys
input = sys.stdin.readline
(q, x) = list(map(int, input().split()))
arr = [0 for i in range(x)]
cur = 0
for i in range(q):
	n = int(input())
	temp = n % x
	arr[temp] += 1
	while arr[cur % x] > 0:
		arr[cur % x] -= 1
		cur += 1
	sys.stdout.write(str(cur) + '\n')


from sys import stdin, stdout
(q, x) = map(int, stdin.readline().split())
mex = 0
l = [0] * (x + 1)
for i in range(q):
	n = int(stdin.readline())
	l[n % x] += 1
	while l[mex % x]:
		l[mex % x] -= 1
		mex += 1
	print(mex)


import sys
input = sys.stdin.readline
import collections

def main():
	(q, X) = [int(x) for x in input().split()]
	C = collections.Counter()
	next = 0
	total = 0
	for _ in range(q):
		y = int(input())
		if y % X == next:
			next += 1
			next %= X
			total += 1
			for i in range(next, next + X + 1):
				if C[i % X] >= 1:
					next += 1
					next %= X
					total += 1
					C[i % X] -= 1
				else:
					break
			print(total)
		else:
			C[y % X] += 1
			print(total)
main()


import sys
import heapq
import math
input = sys.stdin.readline
print = sys.stdout.write
from collections import deque
from collections import defaultdict
from collections import Counter
modH = int(10 ** 9) + 7
I = lambda : list(map(int, input().split(' ')))

def PRINT(lst, sep=' '):
	print(sep.join(map(str, lst)))
(q, x) = I()
mm = q + 1
mex = [0] * (mm + 1)
mex[0] = 0

def findMex(j):
	for i in range(j, len(mex)):
		if mex[i] == 0:
			return i

def findNext(a, mex, x):
	left = 0
	right = 10 ** 9
	best = None
	while left <= right:
		mid = (left + right) // 2
		if a + x * mid > mm or mex[a + x * mid] == 0:
			best = a + x * mid
			right = mid - 1
		else:
			left = mid + 1
	if best <= mm:
		mex[best] = 1
	return best
m = 0
ans = []
for _ in range(q):
	a = int(input())
	bb = findNext(a % x, mex, x)
	m = findMex(m)
	ans.append(m)
PRINT(ans, sep='\n')


import sys
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__

class SegmTree:

	def __init__(self, size):
		N = 1
		while N < size:
			N <<= 1
		self.N = N
		self.tree = [(float('inf'), -1) for _ in range(2 * N)]
		for i in range(size):
			self.tree[i + N] = (0, i)
		self.build()

	def build(self):
		for i in range(self.N - 1, 0, -1):
			self.tree[i] = min(self.tree[i << 1], self.tree[i << 1 | 1])

	def inc(self, i):
		tree = self.tree
		i += self.N
		(occ, rem) = tree[i]
		tree[i] = (occ + 1, rem)
		while i > 1:
			tree[i >> 1] = min(tree[i], tree[i ^ 1])
			i >>= 1

	def query_range(self, l, r):
		tree = self.tree
		l += self.N
		r += self.N
		result = (float('inf'), -1)
		while l < r:
			if l & 1:
				result = min(result, tree[l])
				l += 1
			if r & 1:
				r -= 1
				result = min(result, tree[r])
			l >>= 1
			r >>= 1
		return result
(q, x) = map(int, input().split())
st = SegmTree(x)
for _ in range(q):
	val = int(input())
	st.inc(val % x)
	(minOcc, rem) = st.tree[1]
	mex = minOcc * x + rem
	print(mex)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, x) = map(int, input().split())
t = 0
d = dict()
for i in range(n):
	s = int(input())
	if s % x in d:
		d[s % x] += 1
	else:
		d.update({s % x: 1})
	while t % x in d:
		d[t % x] -= 1
		if d[t % x] == 0:
			del d[t % x]
		t += 1
	print(t)


import sys
input = sys.stdin.readline
(q, x) = map(int, input().split())
r = [0] * x
ans = 0
for _ in range(q):
	y = int(input())
	r[y % x] += 1
	while r[ans % x]:
		r[ans % x] -= 1
		ans += 1
	print(ans)


(q, x) = map(int, input().split())
(a, m, s) = ([0] * (x + 1), 0, '')
while q > 0:
	q -= 1
	a[int(input()) % x] += 1
	while a[m % x] > 0:
		a[m % x] -= 1
		m += 1
	s += str(m) + '\n'
print(s)


(q, x) = map(int, input().split(' '))
d = [0] * x
mex = 0
ans = []
for i in range(q):
	a = int(input())
	d[a % x] += 1
	while d[mex % x] > 0:
		d[mex % x] -= 1
		mex += 1
	ans.append(mex)
print(*ans, end='\n')


import atexit
import io
import sys
input = sys.stdin.readline
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
fout = lambda args: sys.stdout.write(' '.join((str(i) for i in args)) + '\n')
(q, x) = map(int, input().split())
cnt = [0] * x
mex = 0
for _ in range(q):
	a = int(input())
	cnt[a % x] += 1
	while cnt[mex % x]:
		cnt[mex % x] -= 1
		mex += 1
	fout([mex])


import sys
import math
from collections import defaultdict, Counter
input = sys.stdin.readline

def print(x):
	sys.stdout.write(str(x) + '\n')
st = set(range(4 * 10 ** 5, -1, -1))
(q, x) = map(int, input().split())
v = {}
p = 0
for i in range(q):
	y = int(input())
	d = y // x
	y -= d * x
	if 0 <= y <= 4 * 10 ** 5:
		if y not in v:
			v[y] = 1
		else:
			y1 = y
			y += v[y] * x
			v[y1] += 1
		st.discard(y)
	while p not in st:
		p += 1
	print(p)


from sys import stdin
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin

def ii():
	return int(stdin.readline())

def fi():
	return float(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def lsi():
	x = list(stdin.readline())
	x.pop()
	return x

def si():
	return stdin.readline()

def sieve(x):
	a = [True] * (x + 1)
	sq = floor(sqrt(x))
	for i in range(3, sq + 1, 2):
		if a[i]:
			for j in range(i * i, x + 1, i):
				a[j] = False
	if x > 1:
		p = [2]
	else:
		p = []
	for i in range(3, x + 1, 2):
		if a[i]:
			p.append(i)
	return p
(n, m) = mi()
d = dict()
p = 0
s = set()
for _ in range(n):
	x = ii()
	x %= m
	if x in d:
		d[x] += m
	else:
		d[x] = x
	s.add(d[x])
	while p in s:
		p += 1
	print(p)


import sys
input = sys.stdin.readline
from collections import defaultdict

def main():
	(q, x) = [int(s) for s in input().split()]
	a = set()
	d = {}
	ans = 0
	ans1 = 0
	c = defaultdict(int)
	for i in range(q):
		y = int(input())
		c[y % x] += 1
		while c[ans % x] > 0:
			c[ans % x] -= 1
			ans = (ans + 1) % x
			if ans == 0:
				ans1 += 1
		print(ans + ans1 * x)
main()


from collections import Counter
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
import math
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(q, x) = gil()
h = list(range(4 * int(100000.0) + 5))
heapify(h)
used = set()
mul = 2 * (math.ceil(int(1000000000.0) / x) + 1)
for _ in range(q):
	(y,) = gil()
	y = y % x
	(l, r) = (0, mul)
	fnum = None
	while l <= r:
		mid = (l + r) // 2
		num = mid * x + y
		if num in used:
			l = mid + 1
		else:
			r = mid - 1
			fnum = num
	used.add(fnum)
	while h[0] in used:
		heappop(h)
	print(h[0])


import sys
import atexit
import io
from collections import defaultdict, Counter
sys.setrecursionlimit(10 ** 9)
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

def main():
	(q, x) = [int(s) for s in input().split()]
	a = set()
	d = {}
	ans = 0
	ans1 = 0
	c = defaultdict(int)
	for i in range(q):
		y = int(input())
		c[y % x] += 1
		while c[ans % x] > 0:
			c[ans % x] -= 1
			ans = (ans + 1) % x
			if ans == 0:
				ans1 += 1
		print(ans + ans1 * x)
main()


from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n').split(' ')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
currcount = 0
(q, x) = li()
d = defaultdict(int)
lastmin = defaultdict(int)
for i in range(q):
	ele = val()
	if not lastmin[ele % x]:
		lastmin[ele % x] = 1
	else:
		lastmin[ele % x] += 1
	d[x * (lastmin[ele % x] - 1) + ele % x] = 1
	while d[currcount]:
		currcount += 1
	print(currcount)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy
(q, x) = list(map(int, input().strip().split(' ')))
c = [0] * x
mex = 0
ans = []
for i in range(q):
	y = int(input().strip())
	c[y % x] += 1
	while c[mex % x] > mex / x:
		mex += 1
	ans.append(mex)
print('\n'.join(map(str, ans)))


from math import *
from sys import *
(q, x) = map(int, stdin.readline().split())
m = [0] * x
ar = [0] * (q + 1)
y = 0
for o in range(q):
	n = int(stdin.readline())
	mod = n % x
	c = m[mod] * x + mod
	m[mod] += 1
	if c <= q:
		ar[c] += 1
	for i in range(y, q + 1):
		if ar[i] == 0:
			print(i)
			y = i
			break


(q, x) = map(int, input().split())
cnt = [0 for i in range(x + 1)]
cur = 0
ans = []
for i in range(q):
	y = int(input())
	cnt[y % x] += 1
	while cnt[cur % x] > 0:
		cnt[cur % x] -= 1
		cur += 1
	ans.append(cur)
print(*ans)


(q, x) = map(int, input().split())
li = [0] * x
output = []
mx = 0
for _ in range(q):
	jth = int(input())
	li[jth % x] += 1
	while li[mx % x]:
		li[mx % x] -= 1
		mx += 1
	output.append(mx)
print(*output)


from sys import stdin, stdout
(q, x) = map(int, stdin.readline().split())
a = [0] * x
mex = 0
for i in range(q):
	e = int(stdin.readline())
	a[e % x] += 1
	while a[mex % x] >= mex // x + 1:
		mex += 1
	print(mex)


import sys
input = sys.stdin.readline
(q, x) = map(int, input().split())
ar = [0] * x
ct = 0
for i in range(q):
	y = int(input())
	if y == ct:
		ct += 1
	else:
		ar[y % x] += 1
	while True:
		if ar[ct % x] > 0:
			ar[ct % x] -= 1
			ct += 1
		else:
			break
	print(ct)


import atexit
import io
import sys
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
a = [1 for _ in range(4 * 10 ** 5 + 1)]
(q, x) = [int(x) for x in input().split()]
removed = {y: 0 for y in range(x)}
c = 0
for _ in range(q):
	query = int(input()) % x
	current = query + x * removed[query]
	removed[query] += 1
	if current < len(a):
		a[current] = 0
	while not a[c]:
		c += 1
		if c >= len(a):
			break
	print(c)


from sys import stdin, stdout

def main():
	arr = list(map(int, stdin.readline().split()))
	N = arr[0]
	X = arr[1]
	counter = dict()
	for i in range(X):
		counter[i] = 0
	maxer = 0
	for i in range(N):
		new_num = int(stdin.readline())
		counter[new_num % X] += 1
		while counter[maxer % X] > 0:
			counter[maxer % X] -= 1
			maxer += 1
		stdout.write(str(maxer) + '\n')
main()


import sys
import math
import itertools
import functools
import collections
import operator

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return '\n'.join(map(str, arr))

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
(q, x) = mi()
d = [0] * x
ans = 0
arr = []
for i in range(q):
	n = ii()
	d[n % x] += 1
	while d[ans % x]:
		d[ans % x] -= 1
		ans += 1
	arr.append(ans)
print(wr(arr))


from sys import stdin, stdout
(q, x) = map(int, stdin.readline().split())
cnt = [0 for i in range(x + 1)]
cur = 0
for i in range(q):
	y = int(stdin.readline())
	cnt[y % x] += 1
	while cnt[cur % x] > 0:
		cnt[cur % x] -= 1
		cur += 1
	stdout.write(str(cur) + '\n')


from sys import stdin, stdout
from math import gcd, sqrt
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
lcm = lambda x, y: x * y // gcd(x, y)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 0 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
(n, k) = R()
a = [0] * k
ln = 1
ind = 0
mx = 0
for i in range(n):
	x = I()
	a[x % k] += 1
	while a[ind] >= ln:
		ind += 1
		mx += 1
		if ind == k:
			ind = 0
			ln += 1
	print(mx)


def zip_sorted(a, b):
	(a, b) = zip(*sorted(zip(a, b)))
	sorted(zip(a, b), key=lambda x: x[1])
	return (a, b)
import sys
from collections import defaultdict
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
S = lambda : list(map(str, input().split()))
(q, x) = I()
if x == 1:
	for t1 in range(q):
		(y,) = I()
		print(t1 + 1)
else:
	from collections import defaultdict
	mem1 = defaultdict(int)
	dp = [0] * (q + 1)
	min_idx = 0
	for t1 in range(q):
		(y,) = I()
		if y % x in mem1:
			if mem1[y % x] < len(dp):
				dp[mem1[y % x]] = 1
				mem1[y % x] = mem1[y % x] + x
				min_idx = dp.index(0, min_idx, q + 1)
				print(min_idx)
			else:
				print(min_idx)
		elif y < min_idx:
			sum1 = y - min_idx % x
			if sum1 + min_idx >= len(dp):
				print(min_idx)
				continue
			else:
				dp[min_idx + sum1] = 1
				mem1[y % x] = min_idx + sum1 + x
				min_idx = dp.index(0, min_idx, q + 1)
				print(min_idx)
		elif y > min_idx:
			sum1 = (y - min_idx) % x
			if sum1 + min_idx >= len(dp):
				print(min_idx)
				continue
			else:
				dp[min_idx + sum1] = 1
				mem1[y % x] = min_idx + sum1 + x
				min_idx = dp.index(0, min_idx, q + 1)
				print(min_idx)
		else:
			dp[min_idx] = 1
			min_idx = dp.index(0, min_idx, q + 1)
			print(min_idx)


def main():
	(q, x) = map(int, input().split())
	a = [0] * x
	rem = 0
	A = []
	for _ in range(q):
		a[int(input()) % x] += 1
		while a[rem % x] != 0:
			a[rem % x] -= 1
			rem += 1
		A.append(rem)
	print('\n'.join(map(str, A)))
	return
main()


import sys
input = sys.stdin.readline
import collections
from collections import defaultdict

def mex_(arr, mex):
	i = mex
	while arr[i] == 1:
		i += 1
	return i
(q, x) = map(int, input().split())
freq = defaultdict(int)
l = [0] * (400000 + 1)
mex = 0
for i in range(q):
	pq = int(input())
	freq[pq % x] += 1
	sub = abs(mex - pq)
	if sub % x == 0:
		l[mex] = 1
		mex = mex_(l, mex)
	else:
		try:
			f = freq[pq % x]
			l[pq % x + (f - 1) * x] = 1
		except:
			pass
	print(mex)


from sys import stdin, stdout
(q, x) = map(int, stdin.readline().split())
cnt = [0 for i in range(x + 1)]
cur = 0
for i in range(q):
	y = int(stdin.readline())
	cnt[y % x] += 1
	while cnt[cur % x] > 0:
		cnt[cur % x] -= 1
		cur += 1
	print(cur)


(n, x) = map(int, input().split())
a = []
c = [0] * x
m = 0
for _ in range(n):
	c[int(input()) % x] += 1
	while c[m % x]:
		c[m % x] -= 1
		m += 1
	a += (m,)
print('\n'.join(map(str, a)))


import sys
(q, x) = list(map(int, sys.stdin.readline().rstrip().split(' ')))
punt = 0
m = [0] * x
for i in range(q):
	y = int(sys.stdin.readline().rstrip())
	m[y % x] += 1
	while m[punt % x] > 0:
		m[punt % x] -= 1
		punt += 1
	print(punt)


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())
(n, m) = mints()
rem = [0] * m
mex = 0
for i in range(n):
	q = mint()
	rem[q % m] += 1
	while rem[mex % m] > 0:
		rem[mex % m] -= 1
		mex += 1
	print(mex)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)

def toord(c):
	return ord(c) - ord('a')
mod = 998244353
INF = float('inf')
from math import factorial, sqrt, ceil, floor
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def main():
	(q, x) = RL()
	hav = [0] * x
	now = 0
	res = []
	for _ in range(q):
		y = N() % x
		hav[y] += 1
		while hav[now % x] > now // x:
			now += 1
		res.append(now)
	for i in res:
		print(i)
main()


from sys import stdin, stdout
from collections import defaultdict
(n, x) = map(int, input().split())
d = defaultdict(int)
if x == 1:
	for i in range(1, n + 1):
		a = int(stdin.readline())
		stdout.write(str(i) + '\n')
else:
	m = 0
	for i in range(n):
		a = int(stdin.readline())
		d[a % x] += 1
		while d[m % x] > 0:
			d[m % x] -= 1
			m += 1
		stdout.write(str(m) + '\n')


from collections import defaultdict as dd
from sys import stdin, stdout
input = stdin.readline
(q, x) = map(int, input().split())
a = []
b = [0] * x
p = 0
m = 0
for _ in range(q):
	i = int(input())
	z = i % x
	b[z] += 1
	while b[p] > m:
		p += 1
		if p == x:
			m += 1
			p = 0
	stdout.write(str(m * x + p) + '\n')


from sys import stdin
input = stdin.buffer.readline
import math
(q, x) = map(int, input().split())
mex = 0
s = set()
d = {}
for i in range(q):
	y = int(input())
	n = y // x
	idd = y - n * x
	if (max(y, mex) - min(y, mex)) % x == 0:
		d[idd] = mex
		s.add(d[idd])
		p = mex
		while p in s:
			p = p + 1
		mex = p
	else:
		if idd in d:
			d[idd] = d[idd] + x
		elif idd > mex:
			d[idd] = idd
		else:
			d[idd] = math.ceil((mex - idd) / x)
		s.add(d[idd])
	print(mex)


from sys import stdin, stdout
qx = list(map(int, stdin.readline().split()))
q = qx[0]
x = qx[1]
dic = {}
s = set()
mex = 0
for i in range(q):
	y = int(stdin.readline())
	m = y % x
	if m not in dic:
		dic[m] = m
		s.add(m)
	else:
		dic[m] += x
		s.add(dic[m])
	while mex in s:
		mex += 1
	stdout.write(str(mex) + '\n')


def ii():
	a = int(input())
	return a

def ai():
	a = list(map(int, input().split()))
	return a

def mi():
	a = map(int, input().split())
	return a
(q, x) = mi()
mex = 0
freq = [0] * x
ans = []
for i in range(q):
	freq[ii() % x] += 1
	while freq[mex % x] > 0:
		freq[mex % x] -= 1
		mex += 1
	ans.append(mex)
print('\n'.join(map(str, ans)))


import sys
input = sys.stdin.readline
(m, maxn) = ({}, int(400000.0))
(t, x) = list(map(int, input().split()))
Mex = 0
for _ in range(t):
	n = int(input())
	ans = int((Mex - n) / x)
	(l, r) = (ans, int((maxn - n) / x))
	mid = l
	while l <= r:
		mid = int((l + r) / 2)
		if n + mid * x in m:
			l = mid + 1
		else:
			r = mid - 1
	m[n + l * x] = 'Lin'
	while Mex in m:
		Mex += 1
	print(Mex)


import os
import sys
from atexit import register
from io import StringIO
sys.stdout = StringIO()
register(lambda : os.write(1, sys.stdout.getvalue().encode()))
ret = 0
[q, x] = [int(n) for n in input().split()]
residues = {}
for n in range(x):
	residues[n] = 0
for _ in range(q):
	y = int(input())
	residues[y % x] += 1
	while residues[ret % x] > 0:
		residues[ret % x] -= 1
		ret += 1
	print(ret)


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
(q, x) = map(int, input().split())
l = set()
for i in range(4 * 10 ** 5 + 1):
	l.add(i)
a = [0] * x
for _ in range(q):
	val = int(input())
	val = val % x
	z = a[val] * x + val
	if z in l:
		l.remove(z)
	a[val] += 1
	for i in l:
		print(i)
		break


import sys
input = sys.stdin.readline
(q, x) = [int(i) for i in input().split()]
dick = [0 for i in range(10 ** 6)]
first_positive = 0
for _ in range(q):
	qi = int(input())
	dick[qi % x] += 1
	while True:
		if dick[first_positive % x] > 0:
			dick[first_positive % x] -= 1
			first_positive += 1
		else:
			break
	print(first_positive)


import os
import sys
from io import BytesIO, IOBase
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import time
start_time = time.time()
import collections as col
import math
from functools import reduce

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
import heapq
MOD = 10 ** 9 + 7

def solve():

	def build(arr):
		for i in range(n):
			tree[n + i] = [0, i]
		for i in range(n - 1, 0, -1):
			(a, b) = (tree[i << 1], tree[i << 1 | 1])
			if a[0] < b[0]:
				tree[i] = a
			elif a[0] > b[0]:
				tree[i] = b
			else:
				tree[i] = [a[0], min(a[1], b[1])]

	def updateTreeNode(p):
		tree[p + n][0] += 1
		i = p + n
		while i > 1:
			i >>= 1
			(a, b) = (tree[i << 1], tree[i << 1 | 1])
			if a[0] < b[0]:
				tree[i] = a
			elif a[0] > b[0]:
				tree[i] = b
			else:
				tree[i] = [a[0], min(a[1], b[1])]
	(Q, n) = getInts()
	tree = [0] * (2 * n)
	A = [0] * n
	build(A)
	for q in range(Q):
		updateTreeNode(getInt() % n)
		print(tree[1][0] * n + tree[1][1])
	return
solve()


from collections import deque
import sys

def inp():
	return sys.stdin.readline().strip()
for _ in range(1):
	(q, x) = map(int, inp().split())
	queries = []
	for i in range(q):
		y = int(inp())
		queries.append(y)
	s = set()
	ans = []
	mex = 0
	mod = {}
	for i in range(q):
		e = queries[i]
		if e % x not in mod:
			mod[e % x] = 0
		mod[e % x] += 1
		s.add(e % x)
		while mex % x in s:
			if mex // x + 1 <= mod[mex % x]:
				mex += 1
			else:
				break
		print(mex)


import bisect
import math
from collections import defaultdict
import os
import sys
from io import BytesIO, IOBase
ii = lambda : int(input())
lmii = lambda : list(map(int, input().split()))
slmii = lambda : sorted(map(int, input().split()))
li = lambda : list(input())
mii = lambda : map(int, input().split())
msi = lambda : map(str, input().split())

class SortedList:

	def __init__(self, iterable=[], _load=200):
		values = sorted(iterable)
		self._len = _len = len(values)
		self._load = _load
		self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
		self._list_lens = [len(_list) for _list in _lists]
		self._mins = [_list[0] for _list in _lists]
		self._fen_tree = []
		self._rebuild = True

	def _fen_build(self):
		self._fen_tree[:] = self._list_lens
		_fen_tree = self._fen_tree
		for i in range(len(_fen_tree)):
			if i | i + 1 < len(_fen_tree):
				_fen_tree[i | i + 1] += _fen_tree[i]
		self._rebuild = False

	def _fen_update(self, index, value):
		if not self._rebuild:
			_fen_tree = self._fen_tree
			while index < len(_fen_tree):
				_fen_tree[index] += value
				index |= index + 1

	def _fen_query(self, end):
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		x = 0
		while end:
			x += _fen_tree[end - 1]
			end &= end - 1
		return x

	def _fen_findkth(self, k):
		_list_lens = self._list_lens
		if k < _list_lens[0]:
			return (0, k)
		if k >= self._len - _list_lens[-1]:
			return (len(_list_lens) - 1, k + _list_lens[-1] - self._len)
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		idx = -1
		for d in reversed(range(len(_fen_tree).bit_length())):
			right_idx = idx + (1 << d)
			if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
				idx = right_idx
				k -= _fen_tree[idx]
		return (idx + 1, k)

	def _delete(self, pos, idx):
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len -= 1
		self._fen_update(pos, -1)
		del _lists[pos][idx]
		_list_lens[pos] -= 1
		if _list_lens[pos]:
			_mins[pos] = _lists[pos][0]
		else:
			del _lists[pos]
			del _list_lens[pos]
			del _mins[pos]
			self._rebuild = True

	def _loc_left(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(lo, pos) = (-1, len(_lists) - 1)
		while lo + 1 < pos:
			mi = lo + pos >> 1
			if value <= _mins[mi]:
				pos = mi
			else:
				lo = mi
		if pos and value <= _lists[pos - 1][-1]:
			pos -= 1
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value <= _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def _loc_right(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(pos, hi) = (0, len(_lists))
		while pos + 1 < hi:
			mi = pos + hi >> 1
			if value < _mins[mi]:
				hi = mi
			else:
				pos = mi
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value < _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def add(self, value):
		_load = self._load
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len += 1
		if _lists:
			(pos, idx) = self._loc_right(value)
			self._fen_update(pos, 1)
			_list = _lists[pos]
			_list.insert(idx, value)
			_list_lens[pos] += 1
			_mins[pos] = _list[0]
			if _load + _load < len(_list):
				_lists.insert(pos + 1, _list[_load:])
				_list_lens.insert(pos + 1, len(_list) - _load)
				_mins.insert(pos + 1, _list[_load])
				_list_lens[pos] = _load
				del _list[_load:]
				self._rebuild = True
		else:
			_lists.append([value])
			_mins.append(value)
			_list_lens.append(1)
			self._rebuild = True

	def discard(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_right(value)
			if idx and _lists[pos][idx - 1] == value:
				self._delete(pos, idx - 1)

	def remove(self, value):
		_len = self._len
		self.discard(value)
		if _len == self._len:
			raise ValueError('{0!r} not in list'.format(value))

	def pop(self, index=-1):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		value = self._lists[pos][idx]
		self._delete(pos, idx)
		return value

	def bisect_left(self, value):
		(pos, idx) = self._loc_left(value)
		return self._fen_query(pos) + idx

	def bisect_right(self, value):
		(pos, idx) = self._loc_right(value)
		return self._fen_query(pos) + idx

	def count(self, value):
		return self.bisect_right(value) - self.bisect_left(value)

	def __len__(self):
		return self._len

	def __getitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		return self._lists[pos][idx]

	def __delitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		self._delete(pos, idx)

	def __contains__(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_left(value)
			return idx < len(_lists[pos]) and _lists[pos][idx] == value
		return False

	def __iter__(self):
		return (value for _list in self._lists for value in _list)

	def __reversed__(self):
		return (value for _list in reversed(self._lists) for value in reversed(_list))

	def __repr__(self):
		return 'SortedList({0})'.format(list(self))

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def main():
	mex = []
	d = defaultdict(int)
	for i in range(0, 10 ** 6):
		mex.append(i)
		d[i] = -1
	mex = SortedList(mex)
	(q, x) = mii()
	for i in range(q):
		y = ii()
		val = y - x * (y // x)
		if i == 0:
			mex.discard(val)
			d[val] = val
		elif mex[0] == y:
			mex.discard(y)
			d[val] = y
		else:
			if d[val] == -1:
				d[val] = val
			else:
				d[val] += x
			mex.discard(d[val])
		print(mex[0])
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
input = sys.stdin.readline
(q, x) = list(map(int, input().split()))
array = [0] * x
ans = 0
for _ in range(q):
	n = int(input())
	array[n % x] += 1
	while array[ans % x]:
		array[ans % x] -= 1
		ans += 1
	print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
(n, x) = Ri()
mex = 0
dic = {}
s = set()
for i in range(n):
	num = int(ri())
	dic[num % x] = dic.get(num % x, 0) + 1
	while mex % x in dic:
		dic[mex % x] -= 1
		if dic[mex % x] == 0:
			dic.pop(mex % x)
		mex += 1
	print(mex)


import math, collections, sys
input = sys.stdin.readline
(q, x) = map(int, input().split())
s = set()
mex = 0
z = [0 for i in range(x)]
for _ in range(q):
	y = int(input())
	z[y % x] += 1
	while z[mex % x]:
		z[mex % x] -= 1
		mex += 1
	print(mex)


import sys
input = sys.stdin.readline
(Q, x) = map(int, input().split())
ans = 0
rem = [0] * x
L = []
for i in range(Q):
	N = int(input())
	rem[N % x] += 1
	while rem[ans % x] > 0:
		rem[ans % x] -= 1
		ans += 1
	print(ans)


import sys
input = sys.stdin.buffer.readline
(q, x) = [int(x) for x in input().split()]
nIsCovered = [False for _ in range(4 * 10 ** 5 + 1)]
multipleNotCovered = [0 for _ in range(x)]
currMEX = 0
for _ in range(q):
	n = int(input())
	m = n % x
	z = multipleNotCovered[m]
	if m + x * z < len(nIsCovered):
		nIsCovered[m + x * z] = True
	multipleNotCovered[m] += 1
	while nIsCovered[currMEX] == True:
		currMEX += 1
	print(currMEX)


import sys
(q, x) = map(int, input().split())
arr = [0] * x
n = 0
for _ in range(q):
	num = int(sys.stdin.readline())
	arr[num % x] += 1
	while arr[n % x]:
		arr[n % x] -= 1
		n += 1
	print(n)


from sys import stdin
input = stdin.readline
(n, x) = map(int, input().split())
przyst = [0] * x
l = []
best = 0
for i in range(n):
	nju = int(input())
	przyst[nju % x] += 1
	while True:
		if przyst[best % x] != 0:
			best += 1
			przyst[(best - 1) % x] -= 1
		else:
			break
	print(best)


import sys
input = sys.stdin.readline
import math
import copy
import collections
from collections import deque
inf = 10 ** 18
(q, x) = map(int, input().split())
quer = []
for i in range(q):
	quer.append(int(input()))
counts = dict()
for i in range(x):
	counts[i] = 0
prev = 0
index = 0
for i in range(q):
	temp = quer[i] % x
	counts[temp] += 1
	if temp == prev % x:
		while True:
			prev += 1
			index += 1
			index %= x
			if prev // x + 1 > counts[index]:
				break
	print(prev)


import sys
import atexit
import io
from collections import defaultdict, Counter
sys.setrecursionlimit(10 ** 9)
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
import sys, time
start_time = time.time()
MAX_N = int(400000.0 + 50)
(q, x) = map(int, input().split())
ans = 0
visited = [0 for _ in range(x)]
for _ in range(q):
	y = int(input())
	visited[y % x] += 1
	while visited[ans % x] != 0:
		visited[ans % x] -= 1
		ans += 1
	sys.stdout.write(str(ans) + '\n')


from heapq import *
(q, x) = map(int, input().split())
(queue, mem, ans, mi) = ([[0, i] for i in range(x)], [0] * x, [], 0)
heapify(queue)
for i in range(q):
	n = int(input())
	cur = n % x
	mem[cur] += 1
	heappush(queue, [mem[cur], cur])
	while queue:
		ele = queue[0]
		if mem[ele[1]] == ele[0]:
			ans.append(str(ele[0] * x + ele[1]))
			break
		else:
			heappop(queue)
print('\n'.join(ans))


import io
import os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(q, x) = map(int, input().split())
numbers = [0] * x
m = 0
for _ in range(q):
	numbers[int(input()) % x] += 1
	while numbers[m % x] != 0:
		numbers[m % x] -= 1
		m += 1
	print(m)


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])


from sys import stdin, stdout

def main():
	(q, x) = map(int, stdin.readline().split())
	cnt = [0] * 400010
	menor = 0
	for c in range(q):
		a = int(stdin.readline()) % x
		cnt[a] += 1
		while cnt[menor % x] > menor // x:
			menor += 1
		stdout.write(str(menor) + '\n')
main()


import sys
inp = sys.stdin.readline
input = lambda : inp().strip()
flush = sys.stdout.flush

def iin():
	return int(input())

def lin():
	return list(map(int, input().split()))

def main():
	(q, x) = lin()
	mx = 4 * 10 ** 5 + 1 + x
	ch = 0
	fact = [[] for i in range(x)]
	for _ in range(q):
		y = iin()
		fact[y % x].append(y)
		while ch < mx:
			if fact[ch % x]:
				fact[ch % x].pop()
				ch += 1
			else:
				break
		print(ch)
main()


import sys
input = sys.stdin.readline
(q, x) = map(int, input().split())
mex = 0
a = [0 for i in range(x)]
for i in range(q):
	y = int(input())
	a[y % x] += 1
	while a[mex % x] > 0:
		a[mex % x] -= 1
		mex += 1
	print(mex)


import sys
from bisect import bisect_left as bl, bisect_right as br, bisect
import math
from timeit import default_timer as dt
from itertools import zip_longest as zl
from itertools import groupby as gb
from itertools import combinations as comb
from itertools import combinations_with_replacement as cwr
from collections import defaultdict as dd
from collections import deque as dq
from collections import Counter as c
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(var)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [[val for i in range(n)] for j in range(m)]
(q, x) = sp()
a = l1d(x)
ans = 0
for _ in range(q):
	y = int(data())
	a[y % x] += 1
	while a[ans % x]:
		a[ans % x] -= 1
		ans += 1
	out(str(ans) + '\n')


import sys
(n, x) = map(int, sys.stdin.readline().split())
data = [0] * x
cur_res = 0
level = 0
for _ in range(n):
	num = int(sys.stdin.readline()) % x
	data[num] += 1
	pos = cur_res % x
	if num == pos:
		done = False
		for i in range(pos, x):
			if data[i] > level:
				cur_res += 1
			else:
				done = True
				break
		if not done:
			level += 1
		while not done:
			for i in range(x):
				if data[i] > level:
					cur_res += 1
				else:
					done = True
					break
			if not done:
				level += 1
	print(cur_res)


(q, x) = map(int, input().split())
list1 = [0] * x
list2 = []
count = 0
for i in range(q):
	p = int(input())
	list1[p % x] += 1
	while list1[count % x] != 0:
		list1[count % x] -= 1
		count += 1
	list2.append(count)
print(*list2)


from sys import stdin, stdout
from os import path
if path.exists('input.txt'):
	stdin = open('input.txt', 'r')

def next(arr, m, l):
	r = l
	for i in range(m, l):
		if arr[i] == 0:
			r = i
			return r
	return r
(g, x) = map(int, stdin.readline().strip().split())
count = [0] * x
start = 0
minInd = 0
out = 0
for _ in range(g):
	j = int(stdin.readline())
	modex = j % x
	count[modex] += 1
	if modex == minInd:
		w = next(count, minInd, x)
		if w < x:
			minInd = w
			out = start + minInd
			stdout.write(str(out) + '\n')
			continue
		else:
			start += x
			for i in range(x):
				count[i] -= 1
			minInd = next(count, 0, x)
			out = start + minInd
			stdout.write(str(out) + '\n')
			continue
	else:
		out = start + minInd
		stdout.write(str(out) + '\n')


import atexit
import io
import sys
input = sys.stdin.readline
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
import sys, time
input = sys.stdin.readline
start_time = time.time()
MAX_N = int(400000.0 + 50)
(q, x) = map(int, input().split())
ans = 0
visited = [0 for _ in range(x)]
for _ in range(q):
	y = int(input())
	visited[y % x] += 1
	while visited[ans % x] != 0:
		visited[ans % x] -= 1
		ans += 1
	sys.stdout.write(str(ans) + '\n')


import os
import sys
from io import BytesIO, IOBase
_str = str
str = lambda x=b'': x if type(x) is bytes else _str(x).encode()
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
input = lambda : sys.stdin.readline().rstrip('\r\n')
(q, x) = map(int, input().split())
Table = [0] * x
hunting = 0
for i in range(q):
	val = int(input()) % x
	Table[val] += 1
	while Table[hunting % x] > 0:
		Table[hunting % x] -= 1
		hunting += 1
	print(hunting)


from sys import stdin, stdout

def main():
	(q, x) = map(int, stdin.readline().split())
	mex = 0
	m = [0] * x
	i = 0
	for j in range(q):
		el = int(stdin.readline())
		m[el % x] += 1
		while m[i % x] > 0:
			m[i % x] -= 1
			i += 1
		stdout.write(str(i) + '\n')
main()


import atexit
import io
import sys
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
from collections import defaultdict
(q, x) = map(int, input().split())
mex = 0
pending = defaultdict(int)
for _ in range(q):
	y = int(input())
	pending[y % x] += 1
	while pending[mex % x] > 0:
		pending[mex % x] -= 1
		mex += 1
	print(mex)


from array import array
(q, x) = tuple(map(int, input().split()))
count = array('i', [0] * x)
arr = [int(input()) % x for _ in range(q)]
mex = 0
mexs = []
for p in arr:
	count[p] += 1
	while count[mex % x] > 0:
		count[mex % x] -= 1
		mex += 1
	mexs.append(str(mex))
print('\n'.join(mexs))


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(T, X) = map(int, input().split())
A = []
C = [0] * X
N = 0
for _ in range(T):
	C[int(input()) % X] += 1
	while C[N % X]:
		C[N % X] -= 1
		N += 1
	A += (N,)
print('\n'.join(map(str, A)))


import heapq
import sys
input = sys.stdin.readline
(q, x) = map(int, input().split())
h = dict()
t = 0
p = dict()
for i in range(q):
	a = int(input())
	a = a % x
	if a in p:
		a = p[a]
	else:
		p[a] = a
	while a in h:
		a += x
	if a not in h:
		p[a % x] = a
		h[a] = 1
	while t in h:
		t += 1
	print(t)


import sys
input = sys.stdin.readline
(q, x) = map(int, input().split())
Table = [0] * x
hunting = 0
for i in range(q):
	val = int(input()) % x
	Table[val] += 1
	while Table[hunting % x] > 0:
		Table[hunting % x] -= 1
		hunting += 1
	print(hunting)


import sys
(q, x) = map(int, sys.stdin.readline().strip().split())
mxN = 4 * 10 ** 5 + 1
mex = 0
a = {i: 0 for i in range(x)}
need_to_mex = 0
mn = 0
needCheck = False
for query in range(q):
	n = int(sys.stdin.readline().strip()) % x
	a[n] += 1
	if n == need_to_mex:
		if needCheck:
			mn = mxN
			mx = -1
			pos_mn = 0
			for k in a:
				if a[k] < mn:
					mn = a[k]
					pos_mn = k
			need_to_mex = pos_mn
			mex = mn * x + pos_mn
			if pos_mn > 0 and mn < a[pos_mn - 1] or (pos_mn < x and mn < a[pos_mn + 1]):
				needCheck = True
			else:
				needCheck = False
		else:
			mex += 1
			need_to_mex += 1
			if need_to_mex >= x:
				need_to_mex = 0
	else:
		needCheck = True
	print(mex)


import sys
import math
input = sys.stdin.readline
(q, x) = map(int, input().split())
a = list()
for i in range(x):
	a.append(i)
dc = dict()
res = 0
mex = 0
for _ in range(q):
	y = int(input())
	y = y % x
	dc[a[y]] = 1
	while True:
		if res not in dc.keys():
			print(res)
			break
		res += 1
	a[y] += x


from sys import stdin, stdout
res = 0
d = [0 for i in range(400005)]
(q, x) = map(int, stdin.readline().split())
for _ in range(q):
	n = int(stdin.readline())
	d[n % x] += 1
	while d[res % x] > res / x:
		res += 1
	stdout.write('%s' % res + '\n')


import sys
input = sys.stdin.buffer.readline
(q, x) = map(int, input().split())
a = [0 for i in range(x)]
b = []
for i in range(q):
	n = int(input())
	a[n % x] += 1
	b.append(n)
dict = {}
for i in range(x):
	dict[i] = a[i]
s = []
store = 0
mini = 9999999999
for i in range(x):
	if a[i] < mini:
		mini = a[i]
		store = i
y = x * a[store] + store
pre_i = store
pre_j = a[store]
for i in range(q - 1, 0, -1):
	dict[b[i] % x] -= 1
	if dict[b[i] % x] == pre_j and b[i] % x <= pre_i:
		pre_i = b[i] % x
		pre_j = dict[b[i] % x]
	elif dict[b[i] % x] < pre_j:
		pre_i = b[i] % x
		pre_j = dict[b[i] % x]
	s.append(pre_j * x + pre_i)
for i in range(q - 2, -1, -1):
	print(s[i])
print(y)


(q, x) = map(int, input().split(' '))
my_list = []
for i in range(q):
	my_list.append(int(input()))
count = [0] * x
mex = 0
for a in my_list:
	count[a % x] += 1
	while True:
		if count[mex % x] > 0:
			count[mex % x] -= 1
			mex += 1
		else:
			break
	print(mex)


import io
import os
from collections import Counter, defaultdict, deque

def solve(Q, X, queries):
	freq = Counter()
	ans = []
	mex = 0
	wholeRows = 0
	for y in queries:
		freq[y % X] += 1
		while freq[mex % X] >= wholeRows + 1:
			mex += 1
			if mex % X == 0:
				wholeRows += 1
		ans.append(mex)
	return '\n'.join(map(str, ans))
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(Q, X) = [int(x) for x in input().split()]
queries = []
for i in range(Q):
	(y,) = [int(x) for x in input().split()]
	queries.append(y)
ans = solve(Q, X, queries)
print(ans)


def build(v, l, r):
	if l == r:
		do[v] = l
	else:
		m = (l + r) // 2
		build(2 * v, l, m)
		build(2 * v + 1, m + 1, r)
		do[v] = min(do[2 * v + 1], do[2 * v])

def update(v, l, r, value):
	if l == r:
		do[v] = 1000000000.0
	else:
		m = (l + r) // 2
		if value <= m:
			update(2 * v, l, m, value)
		else:
			update(2 * v + 1, m + 1, r, value)
		do[v] = min(do[2 * v + 1], do[2 * v])
import sys
(q, x) = map(int, input().split())
mods = [-1] * x
do = [0] * 4 * q
build(1, 0, q)
g = sys.stdin.readlines()
for i in range(q):
	y = int(g[i].replace('\n', ''))
	mods[y % x] += 1
	update(1, 0, q, mods[y % x] * x + y % x)
	print(do[1])