import sys n, k = [ int(v) for v in input().split() ] border = ( n - 1 ) % ( k + 1 ) if border == 0: output = 0 else: output = border print(str(output)+"\n", flush=True) while True: m = int(input()) if m > n: sys.exit() else: x = m % ( k + 1 ) y = m + k + 1 - x print(str(y)+"\n", flush=True)