func2::[Int] -> [Int] -> Int
func2 [_] _ = 0
func2 (a:as) cs = if head as - a == 1 then (cs!!(a-1)) + (func2 as cs) else (func2 as cs)

main::IO ()
main = do
    _ <- getLine
    a <- map read . words <$> getLine
    b <- map read . words <$> getLine
    c <- map read . words <$> getLine
    let count = func2 a c
    print count
    print $ (+count) $ sum b