open System let read() = Console.ReadLine().Split() |> Array.map (int) let N,M = let t = read() in t.[0],t.[1] let A = read() A |> Array.fold (fun acc x -> match x with | 1 -> acc | x when x = N -> acc.[x-1]::acc.[..(x-2)] | x -> acc.[x-1]::acc.[..(x-2)]@acc.[x..] ) [1..N] |> List.head |> printfn "%i"