package main import ( "bufio" "fmt" "os" "strconv" ) var sc = bufio.NewScanner(os.Stdin) var rdr = bufio.NewReaderSize(os.Stdin, 1000000) func main() { sc.Split(bufio.ScanWords) n, k := nextInt(), nextInt() mod := 0 if !(k >= n || n%(k+1) != 1) { fmt.Println(0) } else { mod = n%(k+1) - 1 if mod == -1 { mod = k } fmt.Println(mod) } for { os.Stdout.Sync() ans := nextInt() if ans >= n { return } m := (ans - mod) % (k + 1) fmt.Println(ans + k + 1 - m) } } func nextLine() string { sc.Scan() return sc.Text() } func nextInt() int { i, _ := strconv.Atoi(nextLine()) return i }