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)) while True: m = int(input()) if m > n: pass else: x = m % ( k + 1 ) y = m + k + 1 - x print(y)