n, k = [ int(v) for v in input().split() ]
border = ( n - 1 ) % ( k + 1 )

if border == 0:
	output = 0
else:
	output = border

print(output)

stop = 0
while True:
	m = int(input())
	if m >= n:
		stop = 1
		break
	x = m % ( k + 1 )
	y = m + k + 1 - x 
	print(y)