getBonusScore :: [Int] -> [Int] -> Int -> Int
getBonusScore inList cList ans
 | null inList = ans
 | otherwise   = getBonusScore (tail inList) cList $ ans + ( cList !! (head inList - 2) )

main = do
 getLine
 aList <- map read . words <$> getLine :: IO [Int]
 bList <- map read . words <$> getLine :: IO [Int]
 cList <- map read . words <$> getLine :: IO [Int]
 let normalScore = sum bList
 let bonuxIndex = filter (\x -> x /= 0) . zipWith (*) aList $ 0:(map (\x -> if x == 1 then 1 else 0) $ zipWith (-) (tail aList) aList)
 print $ (getBonusScore bonuxIndex cList 0) + normalScore