import qualified Data.ByteString.Char8 as BS
import Data.Maybe (fromJust)
import Data.List

main :: IO ()
main = do
    n <- readLn :: IO Int
    a <- map (fst . fromJust . BS.readInt)
        . BS.words <$> BS.getLine :: IO [Int]
    b <- map (fst . fromJust . BS.readInt)
        . BS.words <$> BS.getLine :: IO [Int]
    let a' = sort a
        b' = sort b
        check = and $ zipWith (<=) a' b'
        ab = zip a b
        ab' = zip a' b'
        cnt = sum [ 1 | x <- ab, x `notElem` ab']
    putStrLn $ if check && cnt <= 6 then "Yes" else "No"
