import Control.Applicative
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

readi b | Just (n, _) <- B.readInt b = n

f xs = (head xs, length xs)

g _  [] = True
g [] _  = False
g ((da, db):ds) ((ta, tb):ts)
    | da < ta   = g ds ((ta, tb):ts)
    | da > ta   = False
    | db >= tb  = g ds ts
    | otherwise = False

main = do
    n <- readLn :: IO Int
    ds <- fmap f . group . sort . fmap readi . B.words <$> B.getLine
    m <- readLn :: IO Int
    ts <- fmap f . group . sort . fmap readi . B.words <$> B.getLine
    if g ds ts
        then putStrLn "YES"
        else putStrLn "NO"