import Data.List main = getLine >> getContents >>= putStrLn . solve . map (map read . words) . lines solve :: [[Int]] -> String solve [zs, ys] | acc' < mnum' = "NO" | otherwise = "YES" where (acc', mnum', _) = foldl ff (0, 0, zs) ys ff (acc, mnum, xs) y | y == 0 = (acc + head x', max mnum $ head x', xs') | otherwise = (acc, max mnum $ head x', xs') where (x', xs') = splitAt 1 xs