use strict; use warnings; $| = 1; my($n, $k) = split ' ', <>; my $ans = ($n-1) % ($k+1); print $ans."\n"; my $opp; while(1){ $opp = <>; last if($n <= $opp); $ans = $opp + ($k+1 - ($opp - $ans)); print $ans."\n"; }