import Control.Monad
import Data.List

main = do
    n <- readLn :: IO Int
    as <- map read . words <$> getLine :: IO [Int]
    let as' = dropWhile (<=1) $ map length $ group $ sort as
    putStrLn $ if null as' then "YES" else "NO"