f::[Int]->[Int]->[Int]->Int
f [] ys zs = 0
f [x] ys zs = ys!!(x-1)
f [x,y] ys zs = if x+1 == y then ys!!(x-1) + ys!!(y-1) + zs!!(x-1)  else ys!!(x-1) + ys!!(y-1) 
f (x:y:xs) ys zs = if x+1 == y then ys!!(x-1) + ys!!(y-1) + zs!!(x-1) + f(y:xs) ys zs else ys!!(x-1) + ys!!(y-1) + f(y:xs) ys zs
main = do
    getLine
    a<- map read.words<$>getLine
    b<- map read.words<$>getLine
    c<-map read.words<$>getLine
    print $ f a b c