kr :: [Int] -> [Int] -> Int
kr [x] _ = 0
kr a c = if a!!0 + 1 == a!!1 then c !! (a!!0 - 1) + kr (tail a) c else kr (tail a) c

main = do
    _ <- getLine
    a <- map read . words <$> getLine :: IO [Int]
    b <- map read . words <$> getLine :: IO [Int]
    c <- map read . words <$> getLine :: IO [Int]
    print $ sum b + kr a c
