let n = (stdin.ReadLine >> int) ()
let hs = stdin.ReadLine().Split(' ') |> Array.map int |> Array.toList

let f (xs: int list) =
    let rec loop (xs: int list) (p: int) b =
        if not b then false
        else match xs with
             | [] -> b
             | y::ys -> if p <= y-1 then loop ys (y-1) true
                        elif p = y then loop ys y true
                        else loop ys y false
    loop xs xs.[0] true

if f hs then printfn "Yes"
else printfn "No"