import Data.List

main = do
  n <- readLn :: IO Int
  as <- map read . words <$> getLine :: IO [Int]
  putStrLn $ if 0 < check (sort as) then "NO" else "YES"

foldlPairwise :: (a -> b -> b -> a) -> a -> [b] -> a
foldlPairwise f a l = foldl (\a (z, x) -> f a z x) a $ zip l (tail l)

check as = foldlPairwise step 0 as
    where step a z x = a + if z == x then 1 else 0
