k=gets.split[0].to_i xs=[x=0] while x<2e18 do xs.push x+=x/(k-1)+1 end xs.reverse! $<.map{|n|p xs.bsearch{|y|y