import Control.Applicative
import Control.Monad
import Data.Functor
import Data.List

f = (<=2) . length . filter id . zipWith (/=) [1..]

main = getLine >> f . map read . words <$> getLine >>= \p -> putStrLn (if p then "YES" else "NO")