import sys readline=sys.stdin.readline N,K=map(int,readline().split()) N-=1 print(N%(K+1)) while True: A=int(input()) if A>=N: exit() B=A+(-A+N)%(K+1) print(B)