import Data.List
import Data.Char
import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as BS8
import qualified Data.Vector as Vector
import Data.Vector ((!))
import Data.Vector ((//))

main :: IO ()
main = do
  [n, k] <- unfoldr (BS8.readInt . BS8.dropWhile isSpace) <$> BS8.getLine
  ai <- unfoldr (BS8.readInt . BS8.dropWhile isSpace) <$> BS8.getLine

  let
    a = Vector.fromList ai
    iv  = Vector.fromList (replicate n 0)
    (lp, ll)  = getLoop a iv 1 [] 0

  print $ sol n k lp ll

getLoop a v c t i
  | b /= 0  = (take (b + 1) rct, drop (b + 1) rct)
  | b == 0  = getLoop a (v // [(c - 1, i)]) (a ! (c - 1)) ct (i + 1)
  where
    b = v ! (c - 1)
    ct  = c : t
    rct = reverse ct

sol n k lp ll
  | null lp = sol2 n k ll
  | otherwise = if k /= 0 then sol n (k - 1) (tail lp) ll else head lp

sol2 n k ll = ll !! (k `mod` n)
