main :: IO () main = do n <- readLn :: IO Int s <- getLine putStrLn $ if elem s ["0","1","01","10","101","010"] then "NO" else "YES"