N = read_line.to_i
A = read_line.split(" ").map {|str| str.as(Int32)}
B = read_line.split(" ").map {|str| str.as(Int32)}
acc = 0
A.each_with_index do |dish, i|
  acc += B[dish]
  if i > 0 && dish == A[i -1] + 1
  	acc += C[i - 1]
  end
end
acc
  	