using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Text; using System.Text.RegularExpressions; using System.Linq; class Magatro { static void Main() { int N, K; string[] S = Console.ReadLine().Split(' '); N = int.Parse(S[0]); K = int.Parse(S[1]); int T = 0; if (N % (K + 1) == 1) { Console.WriteLine(0); } else { int Q = N % (K + 1); if (Q == 0) { Console.WriteLine(K); T += K; } else { Console.WriteLine(Q - 1); T += Q - 1; } } while (true) { int R = int.Parse(Console.ReadLine()); if (R >= N) { return; } T = R; N -= R; int Q = N % (K + 1); if (Q == 0) { T += K; Console.WriteLine(T); } else { T += Q - 1; Console.WriteLine(T); } } } }