import qualified Data.Set as S

main :: IO ()
main = do
  getLine
  ws <- words <$> getContents
  putStrLn $ solve ws

solve :: [String] -> String
solve (x:xs) = go (last x) (S.singleton x) xs
  where
    go c st [] = "Yes"
    go c st (x:xs)
      | c /= head x = "No"
      | x `S.member` st = "No"
      | otherwise = go (last x) (S.insert x st) xs
