import qualified Data.IntMap as Map import Data.List main :: IO () main = do (n:xs) <- map (read :: String -> Int) . words <$> getContents let ys = take n xs zs = drop n xs ws = zip zs ys us = Map.toList $ Map.fromListWith (+) ws a = head us bs = map snd $ tail us f a bs f :: (Int, Int) -> [Int] -> IO () f a bs | length bs == 0 = if fst a == 0 then putStrLn "YES" else putStrLn "NO" | fst a /= 0 = putStrLn "NO" | maximum bs <= snd a = putStrLn "YES" | otherwise = putStrLn "NO"