import Control.Monad

main = do
  n <- liftM read $ getLine
  ls <- forM [1..n] (\ _ -> getLine)
  putStrLn $ abc109b ls

abc109b ls
  | noDupe ls && connected ls = "Yes"
  | True = "No"

noDupe [] = True
noDupe (x:xs) = null bs && noDupe as && noDupe cs
  where
    (as,bs,cs) = part3 x xs

part3 _ [] = ([],[],[])
part3 p (x:xs) =
  case compare p x of
    LT -> (x:as,bs,cs)
    EQ -> (as,x:bs,cs)
    GT -> (as,bs,x:cs)
  where
    (as,bs,cs) = part3 p xs

connected [] = True
connected xs = and $ zipWith (==) (map last xs) (map head $ tail xs)