import Control.Applicative ((<$>)) main :: IO () main = getLine >> solve <$> getLine >>= putStrLn solve :: String -> String solve "0" = "NO" solve "1" = "NO" solve "01" = "NO" solve "10" = "NO" solve "101" = "NO" solve "010" = "NO" solve _ = "YES"