import Data.Bool

main :: IO ()
main = do
  (n:ps) <- readParams
  putStrLn $ solve [1..n] ps

readParams :: Read a => IO [a]
readParams = map read . words <$> getContents

solve :: [Int] -> [Int] -> String
solve = format .: solve'

format :: Bool -> String
format = bool "NO" "YES"

solve' :: [Int] -> [Int] -> Bool
solve' = (<=2) .: length .: filter (/=0) .: zipWith (-)

infixr 8 .:
(.:) :: (c -> d) -> (a -> b -> c) -> a -> b -> d
(f .: g) x y = f $ g x y
