let split_string ?(pattern=" ") = Str.split @@ Str.regexp pattern
let (n, j) = Scanf.sscanf (read_line ())"%d %d" @@ fun n j -> (n, j)
let a = Array.of_list @@ List.map int_of_string @@ split_string @@ read_line ()
let v = Array.make n 0

let p = ref 0

let rec tp acc i =
  if v.(i) = 1 then (p := i; acc)
  else (v.(i) <- 1; tp (i :: acc) (a.(i) - 1))
let tp = List.rev @@ tp [] 0

let rec loop acc i =
  if i = 0 then print_int (List.hd acc + 1)
  else if !p = (List.hd acc) then let i = i mod (List.length acc) in print_int ((List.nth acc i) + 1)
  else loop (List.tl acc) (i - 1)

let () = loop tp j