main = getLine >> getLine >>= \x ->  putStrLn $ if f ((tail.words) x) [(head.words) x] then "YES" else "NO"
f (s:xs) list = if null xs then not (elem s list) else if elem s list then False else f xs (s:list) 
