main :: IO ()
main = print . solve . map (map read . words) . lines =<< getContents

solve :: [[Int]] -> Int
solve [_,as,bs,cs] = sum [bs !! (a-1) | a <- as] +
  sum [ cs !! (i-1) | (i, j) <- zip as (tail as), i == j - 1]
