Scanf.scanf "%d %d" (fun n m -> let a = Array.init m (fun _ -> Scanf.scanf " %d" (fun a -> a)) in let c = Array.init n (fun i -> i) in Array.iter (fun v -> let q = c.(v - 1) in for j = v - 1 downto 1 do c.(j) <- c.(j - 1) done; c.(0) <- q ) a; Printf.printf "%d\n" @@ c.(0) + 1 )